Android Question [SOLVED] Strange error on one device and not on another device

yfleury

Active Member
Licensed User
Longtime User
Like the title above, I have this error

B4X:
Error occurred on line: 35 (SwiftButton)
java.lang.IllegalArgumentException: width and height must be > 0
    at android.graphics.Bitmap.createBitmap(Bitmap.java:1044)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:1011)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:961)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:922)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:81)
    at anywheresoftware.b4a.objects.B4XCanvas.Initialize(B4XCanvas.java:37)
    at com.fleury.route.map.boss.swiftbutton._designercreateview(swiftbutton.java:289)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:61)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at com.fleury.route.map.boss.main$ResumableSub_sbRecupereClient_Click.resume(main.java:10946)
    at com.fleury.route.map.boss.main._sbrecupereclient_click(main.java:10920)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA$2.run(BA.java:370)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:7002)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
 

emexes

Expert
Licensed User
Check line 35. Only you can see it.

Error occurred on line: 35 (SwiftButton)
java.lang.IllegalArgumentException: width and height must be > 0
 
Last edited:
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
is not on basic code. It's in compiled java code...
In a device, I don't have this error, it occure on a different device.
 
Upvote 0

emexes

Expert
Licensed User
is not on basic code. It's in compiled java code...
But you still have the clues that it is something to do with the width and/or height of a button, and buried in the error dump there is reference to CreateView and LayoutBuilder, so... between those, and knowing which activity of your app the problem happens in, you're on the home stretch here :)
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
In designer on all layout, I check all SwiftButton size. Minimum size for width or height is 65.
I check also in the code for any resize SwiftButton and I have no resize in code.

Test 1:
In designer, I resize all SwiftButton 100 X 100
Same error

Test 2:
In code, I set size for all SwiftButton like this:
SwiftButton.mBase.Height=200dip
SwiftButton.mBase.Width=200dip
Same error

Note: This error occur only when I clic on 2 specific SwiftButton. they load a layout showing task progress. I will investigate in that way
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
Note: This error occur only when I clic on 2 specific SwiftButton. they load a layout showing task progress. I will investigate in that way

I find the problem. My progress task layout (1/4 of screen) was a horizontal anchor for both size. On my 10 inch device the layout is showing ok. But on my 7 inch device, the layout is more smaller and "cut" the SwiftButton and it is not visible. I suppose that produce error. Then I change my horizontal anchor of the layout to the left and no more error.
 
Upvote 0
Top