Bug? [B4X] B4XImageView error during image load at older devices

kiwi

Member
Licensed User
Longtime User
Hello,
I developed app in B4X Pages and used there B4XimageViews. During tests on different devices I found the problem with using B4XImageView at Samsung Galaxy TAB S - SDK 19. Subsequently I used example from tutorial:

with the same problem - crash on the same line according the log (see bellow)

So is there any limit for lower SDKs for using B4XImageView (for ex. min SDK is 25 can use B4XImageView)? Is there any limitation for B4X Pages of min SDK? Or it should work?
I looked for the answer in forum and in B4X Pages Booklet but without success.
Compiled by B4A v12.00

Log:
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
SDK version = 19
Error occurred on line: 162 (B4XImageView)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1057)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1070)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:427)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:247)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:261)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:167)
    at b4a.example.main._activity_create(main.java:418)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    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.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
    at b4a.example.main.afterFirstLayout(main.java:105)
 

emexes

Expert
Licensed User
I developed app

Is there possibly something about the image files that's causing the crash? What if you use smaller images, or png instead of jpeg or vice versa? Perhaps the new images are not straightforward 24-bit colour.

Also maybe try using old original byte-for-byte identical images files from your "old" developed app that does work on that device (presumably).
 

kiwi

Member
Licensed User
Longtime User
No, it is not related to image files. Crash log is from referenced Erel's example where are two small images JPG 49kB and PNG 137kB. I only add there line to show device's SDK in log.
It is related with B4XImageView, when I use standard ImageView it is OK.

But I found solution for low SDKs

B4XImageView example which works:
If device.SdkVersion > 20 Then
        B4XImageView1.Load(File.DirAssets, "1.png")
        B4XImageView2.Load(File.DirAssets, "2.jpg")
Else
        B4XImageView1.mBase.SetBitmap(xui.LoadBitmapResize(File.DirAssets, "1.png", B4XImageView1.mBase.Width, B4XImageView1.mbase.Height, True))
        B4XImageView2.mBase.SetBitmap(xui.LoadBitmapResize(File.DirAssets, "2.jpg", B4XImageView2.mBase.Width, B4XImageView2.mbase.Height, True))
End If

B4XImageView causes crash during image loading :
        B4XImageView1.Load(File.DirAssets, "1.png")
        B4XImageView2.Load(File.DirAssets, "2.jpg")

But when I run the example and use switch for rounded images it will crash again with different log. So not suggest to use this function.

Another crashlog for B4XImageView in tutorial for SDK 19:
--------- beginning of /dev/log/main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
SDK version = 19
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
b4ximageview_updateclip (java line: 290)
java.lang.RuntimeException: Method: setClipToOutline not found in: anywheresoftware.b4a.BALayout
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at b4a.example.b4ximageview._updateclip(b4ximageview.java:290)
    at b4a.example.b4ximageview._setroundedimage(b4ximageview.java:202)
    at b4a.example.b4xmainpage._b4xswitch1_valuechanged(b4xmainpage.java:81)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1180)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5653)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
    at dalvik.system.NativeStart.main(Native Method)
--------- beginning of /dev/log/system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
SDK version = 19
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
 
Top