Android Question java.lang.RunTimeExep - ImageView not initialized

Arf

Well-Known Member
Licensed User
Longtime User
Hi,
I've got a problem that has just started happening since I changed device to Samsung galaxy S3.
I have succesfully ran this project many times on this device, so not sure why it's started now.
Everything is fine on my Nexus 7.

So when I enter one of my activities and load the layout, I get this error:
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at com.medchipsolutions.spiroconnectmobile.forcedtest._activity_create(forcedtest.java:623)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at com.medchipsolutions.spiroconnectmobile.forcedtest.afterFirstLayout(forcedtest.java:102)
at com.medchipsolutions.spiroconnectmobile.forcedtest.access$000(forcedtest.java:17)
at com.medchipsolutions.spiroconnectmobile.forcedtest$WaitForLayout.run(forcedtest.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5365)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:71)
at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:35)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:406)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:425)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:144)
... 22 more

What could possible be causing this?
 

Arf

Well-Known Member
Licensed User
Longtime User
Still totally stuck on this. I've tried to change the image file first loaded in the designer to a few different images, this has no effect.
the original image is only 1.8MB so memory problem seems unlikely.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I see in one of the lines:
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
there seems to be a file called "LayoutBuilder.java" referenced.
A search of my HDD with a search shows that this file is completely absent from my PC, could that have anything to do with it?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
A search of my HDD with a search shows that this file is completely absent from my PC, could that have anything to do with it?
No.

the original image is only 1.8MB so memory problem seems unlikely
Note that the file size is not important. Only the image dimensions are important (width * height).

Can you upload your project?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Thanks Erel.
I can't make the project publically accessible, so I'll send a dropbox link via in a moment.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It works fine here. I tested it on Nexus 5X. You need to check the unfiltered logs (in USB debug mode) and see whether there is any relevant information.

My guess is that the device is running out of memory. Each of the large bitmaps will take about 8mb of memory. Try to resize the images and see whether it helps.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Thanks Erel, much appreciated.

I resized the graph images to 50% (now 634x745), but still encounter the same error on this galaxy S3 phone. This time I captured unfiltered logs and debugged via USB, I shall paste in the relevant section below. Error loading bitmap.. is it clear from the log that is still a memory problem?

** Activity (forcedtest) Create, isFirst = true **
mrvl_ap_dev_stop_output: output 2, stream 1 (hardware output)
change_ref_count: stream 1, count 0
get_new_device: Selected device 0
set_output_device: output 2 device 0 force 0 delayMs 0, path_handler 0
set_output_device: Setting same device 0 or null device for output 2
get_new_device: Selected device 0
--- decoder->decode returned false
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:345)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:425)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:144)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at com.medchipsolutions.spiroconnectmobile.forcedtest._activity_create(forcedtest.java:623)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at com.medchipsolutions.spiroconnectmobile.forcedtest.afterFirstLayout(forcedtest.java:102)
at com.medchipsolutions.spiroconnectmobile.forcedtest.access$000(forcedtest.java:17)
at com.medchipsolutions.spiroconnectmobile.forcedtest$WaitForLayout.run(forcedtest.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5365)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:521)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:499)
at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:69)
at anywheresoftware.b4a.objects.ImageViewWrapper.setImage(ImageViewWrapper.java:90)
at anywheresoftware.b4a.objects.ImageViewWrapper.build(ImageViewWrapper.java:113)
... 28 more
Error occurred on line: 108 (ForcedTest)
GC_CONCURRENT freed 346K, 13% free 12497K/14248K, paused 3ms+5ms, total 43ms
WAIT_FOR_CONCURRENT_GC blocked 16ms
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at com.medchipsolutions.spiroconnectmobile.forcedtest._activity_create(forcedtest.java:623)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at com.medchipsolutions.spiroconnectmobile.forcedtest.afterFirstLayout(forcedtest.java:102)
at com.medchipsolutions.spiroconnectmobile.forcedtest.access$000(forcedtest.java:17)
at com.medchipsolutions.spiroconnectmobile.forcedtest$WaitForLayout.run(forcedtest.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5365)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:71)
at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:35)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:406)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:425)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:144)
... 22 more
 
Upvote 0

An Schi

Well-Known Member
Licensed User
I can't help you with the error - but as long as you are waiting for someone elses reply, i suggest something more radical:
Resize the original image to something like 50x50 and see if it works then.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Good idea - I resized to 63x75, and still the same problem :-(

so probably not a memory issue then, but what else could it be? The bitmap can't be corrupted, it works on all other devices (and this device when not in DEBUG mode).
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Would there be any advantage in changing the image type to reduce any image processing in the rendering?
Would have thought not, bitmap already requires the least amount of decrypting, I think.
 
Upvote 0

strat

Active Member
Licensed User
Longtime User
Did you logged Imageview's width and height after loaded bitmap. How it changes when you loaded bitmap?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
The imageview is set to a portion of screen area by the designer script, and the bitmap is loaded up in FILL mode - so should stretch or shrink to fill the imageview.
I know it all works fine as I've tested the project on loads of devices, it even works on this problematical phone - just not when in DEBUG mode.
Works fine on all other devices in DEBUG..
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I tried that frew times this morning, still the same error.
I've tried using B4A Bridge as well as B4A Bridge Plus as well as USB debugging.
I've attached the whole unfiltered log from the USB debug attempt. Not sure what else I can try.
 

Attachments

  • log.txt
    283.1 KB · Views: 681
Upvote 0
Top