Hello,
i'm having troubles interpreting this exception stack trace
The code that is *probably* causing the exception
The stack trace comes from the phone of a user that has been having issues since the last update of the app, altough this part of the code has been used for several releases for several months. Another app has had this code for years.
I don't think the problem is caused by width or height being < 0 for two reasons:
-In all cases i've encountered the exception explicitely mentioned width/height < 0
-There are checks in the sub that sets the layout, but i concede they may not be 100% bug proof
The device is a Cubot KingKong Mini 2 Rugged phone and while i would be inclined to blame the manufacturer (such phones never work okay in my experience) it's of course not a solution.
I tried generating a simillar device in the simulator (same resolution, memory, android version) and because i suspected something stupid was made by the mfg i also added a device that was forced to run as if landscape and portrait were "swapped" (appereance is portrait, but 100%x is higher than 100%y) but the application launched okay regardless
What can be the other reasons for an IllegalArgumentExcetpion?
i'm having troubles interpreting this exception stack trace
B4X:
java.lang.IllegalArgumentException:
at android.graphics.Bitmap.checkWidthHeight (Bitmap.java:428)
at android.graphics.Bitmap.createBitmap (Bitmap.java:802)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Crop (CanvasWrapper.java:587)
at com.seletron.PedalBooster.main._appsettings_setlayout (main.java:998)
at com.seletron.PedalBooster.main._pnlsettings_setlayout (main.java:3292)
at com.seletron.PedalBooster.main$ResumableSub_Activity_Create.resume (main.java:779)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent (BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:207)
at anywheresoftware.b4a.BA.raiseEvent (BA.java:193)
at anywheresoftware.b4a.keywords.Common$14.run (Common.java:1764)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6711)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:911)
The code that is *probably* causing the exception
B4X:
Dim cvs As B4XCanvas
Dim r As B4XRect
Dim l As Float
Dim t As Float
Dim w As Float
Dim h As Float
[...]
imgBgB.SetLayout(pnlBgSelector.Width/2 - l/2,lblBgChoose.Top + lblBgChoose.Height + vm,l,l) 'Dimensions should all be valid
[...]
w = imgBgB.Width*120.0/200.0
l = (imgBgB.Width-w)/2
t = (imgBgB.Width-w)/2
cvs.Initialize(imgBgB)
r.Initialize(l,t,l+w,t+w)
cvs.ClearRect(cvs.TargetRect)
cvs.DrawBitmap(LoadBitmap(File.DirAssets,"bgHexFlat.png").Crop(l,t,w,w),r) 'only place Bitmap.Crop is explicitely mentioned
cvs.DrawBitmap(LoadBitmap(File.DirAssets,"imgNewBackgroundNotSelected.png"),cvs.TargetRect)
cvs.Invalidate
cvs.Release
The stack trace comes from the phone of a user that has been having issues since the last update of the app, altough this part of the code has been used for several releases for several months. Another app has had this code for years.
I don't think the problem is caused by width or height being < 0 for two reasons:
-In all cases i've encountered the exception explicitely mentioned width/height < 0
-There are checks in the sub that sets the layout, but i concede they may not be 100% bug proof
The device is a Cubot KingKong Mini 2 Rugged phone and while i would be inclined to blame the manufacturer (such phones never work okay in my experience) it's of course not a solution.
I tried generating a simillar device in the simulator (same resolution, memory, android version) and because i suspected something stupid was made by the mfg i also added a device that was forced to run as if landscape and portrait were "swapped" (appereance is portrait, but 100%x is higher than 100%y) but the application launched okay regardless
What can be the other reasons for an IllegalArgumentExcetpion?