Error in Activity.LoadLayout

dimartinoentertainment

Member
Licensed User
Longtime User
Hi

Everything has worked fine before Basic4Android v2.7.
Now, when I try to call an activity using CallSubDelayed, the app sometimes crashes with the following error:

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:19)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:250)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:305)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:305)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:129)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:191)
at com.dimartinoentertainment.moosikay.choosecategory._activity_create(choosecategory.java:279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at com.dimartinoentertainment.moosikay.choosecategory.afterFirstLayout(choosecategory.java:89)


at com.dimartinoentertainment.moosikay.choosecategory.access$100(choosecategory.java:16)
at com.dimartinoentertainment.moosikay.choosecategory$WaitForLayout.run(choosecategory.java:74)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeSample(CanvasWrapper.java:557)
at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:71)
at anywheresoftware.b4a.objects.ImageViewWrapper.setImage(ImageViewWrapper.java:91)
at anywheresoftware.b4a.objects.ImageViewWrapper.build(ImageViewWrapper.java:114)
... 24 more
choosecategory_activity_create (B4A line: 51)
Activity.LoadLayout("choosecat")
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:151)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:191)
at com.dimartinoentertainment.moosikay.choosecategory._activity_create(choosecategory.java:279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at com.dimartinoentertainment.moosikay.choosecategory.afterFirstLayout(choosecategory.java:89)
at com.dimartinoentertainment.moosikay.choosecategory.access$100(choosecategory.java:16)
at com.dimartinoentertainment.moosikay.choosecategory$WaitForLayout.run(choosecategory.java:74)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
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:46)
at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:56)
at anywheresoftware.b4a.objects.ImageViewWrapper.innerInitialize(ImageViewWrapper.java:35)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:290)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:305)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:305)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:129)
... 17 more
sending message to waiting queue (CallSubDelayed - chooseCatSolo)


java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).

I've absolutely no idea what causes it. The error often occures when I try to close the activity and then immediately try to call it again.


Thanks in advance!
 

dimartinoentertainment

Member
Licensed User
Longtime User
** Activity (choosecategory) Create, isFirst = false **
true false
true false
Get MotionRecognitionManager
ssp status : false
GC_FOR_ALLOC freed 11007K, 23% free 50888K/65479K, paused 23ms, total 23ms
Forcing collection of SoftReferences for 5139472-byte allocation
GC_BEFORE_OOM freed 0K, 23% free 50888K/65479K, paused 38ms, total 38ms
Out of memory on a 5139472-byte allocation.
"main" prio=5 tid=1 RUNNABLE
| group="main" sCount=0 dsCount=0 obj=0x40f62508 self=0x40f52468
| sysTid=10944 nice=0 sched=0/0 cgrp=apps handle=1074937648
| schedstat=( 17213717588 4966679074 30708 ) utm=1418 stm=303 core=3
[unregisterDoubleTapMotionListener]
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeSample(CanvasWrapper.java:550)
at anywheresoftware.b4a.objects.drawable.BitmapDrawable.build(BitmapDrawable.java:71)
at anywheresoftware.b4a.objects.ImageViewWrapper.setImage(ImageViewWrapper.java:91)
at anywheresoftware.b4a.objects.ImageViewWrapper.build(ImageViewWrapper.java:114)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:19)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:250)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:305)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:305)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:129)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:191)
at com.dimartinoentertainment.moosikay.choosecategory._activity_create(choosecategory.java:279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at com.dimartinoentertainment.moosikay.choosecategory.afterFirstLayout(choosecategory.java:89)
at com.dimartinoentertainment.moosikay.choosecategory.access$100(choosecategory.java:16)
at com.dimartinoentertainment.moosikay.choosecategory$WaitForLayout.run(choosecategory.java:74)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)

--- decoder->decode returned false
.unregisterListener : / listener count = 0->0, listener=android.widget.AbsListView$4@426cf698
WAIT_FOR_CONCURRENT_GC blocked 0ms
initCheck: 0
detachEffects: detach processing for output 2, stream 1, session 2189
detachEffects: no output processing was attached to this stream
stopOutput() output 2, stream 1, session 2189
changeRefCount() stream 1, count 0
getNewDevice() selected device 0
setOutputDevice() output 2 device 0000 force 0 delayMs 184
setOutputDevice() prevDevice 0002
setOutputDevice() setting same device 0000 or null device for output 2
GC_EXPLICIT freed 5313K, 31% free 45576K/65479K, paused 4ms+4ms, total 37ms

This is the unfiltered output right before the crash.
I see: "Out of memory on a 5139472-byte allocation."
Does it mean that the device has runned out of memory ? Or is this something else ?


Thanks.
 
Upvote 0

dimartinoentertainment

Member
Licensed User
Longtime User
Yes, I've tested some things and it seems indeed that it has to do with loading a large image.

Is there a limit in size or dimension of images ?


Thanks in advance.
 
Upvote 0

dimartinoentertainment

Member
Licensed User
Longtime User
Just to let you know: I've solved the problem by recyling the large bitmap which I"m loading (by using a Reflector).
My app was using between 90%-100% of the available memory. By recyling all the large bitmaps each time the activity closes, the used memory has been reduced to an average of 65%.
 
Upvote 0

thehe

Member
Licensed User
Longtime User
I have the problem with ver3 It away PAUSE at
Activity.LoadLayout("Main")
I tried with simple button CLICK to display a message or to a label.
the program was run on tablet connected to PC with window 7-64
 
Upvote 0
Top