java.lang.ClassCastException

144 views
Skip to first unread message

Anwar Ahmed

unread,
Jun 2, 2016, 2:24:38 AM6/2/16
to MIT App Inventor Forum

Dear all,

I had crash reports from google play saying that:
"java.lang.ClassCastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.LayerDrawable".

My app is in Arabic language and all the phones that have crashes are 5.0 or 5.1.

do you have any idea of what component that may cause the crash.

Thanks a lot

Anwar Ahmed

unread,
Jun 2, 2016, 2:42:44 AM6/2/16
to MIT App Inventor Forum
this is the blocks on the screen that crashes
blocks (4).png

Taifun

unread,
Jun 2, 2016, 10:29:47 AM6/2/16
to MIT App Inventor Forum
Please prepare an example as small as possible, which demonstrates this issue and add the project (aia file) into this thread together with exact instructions for how to elicit the error, so someone can take a look

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Anwar Ahmed

unread,
Jun 5, 2016, 7:19:32 AM6/5/16
to MIT App Inventor Forum
Thanks for your response.
aia is attached,
I don't know what causes the crash, and that is the problem.
The crash only occure on LG, Sony, and HTC devices with android frameware 5.0 to 5.1

The crashing message from google play is

java.lang.RuntimeException: Unable to start activity ComponentInfo{appinventor.ai_ahaanwar2.Shams_copy/appinventor.ai_ahaanwar2.Shams_copy.Screen1}: java.lang.ClassCastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.LayerDrawable
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.ClassCastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.LayerDrawable
at com.google.appinventor.components.runtime.Slider.<init>(Slider.java:100)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at gnu.expr.PrimProcedure.apply(PrimProcedure.java:272)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
at gnu.kawa.reflect.Invoke.applyN(Invoke.java:209)
at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
at appinventor.ai_ahaanwar2.Shams_copy.Screen1.$define(Screen1.yail:10181)
at com.google.appinventor.components.runtime.Form.onCreateFinish(Form.java:334)
at com.google.appinventor.components.runtime.Form.onCreate(Form.java:275)
at android.app.Activity.performCreate(Activity.java:5958)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
... 10 more
Shams_copy.aia

Taifun

unread,
Jun 5, 2016, 10:00:33 AM6/5/16
to MIT App Inventor Forum
I don't know what causes the crash, and that is the problem.
you can find this out and help MIT to get this problem fixed like this: remove some blocks, build again and if the error is still there, remove some more blocks etc.
store a copy of the project from each of the steps
and if the error is gone then go back one step and remove some other blocks etc.until in the end you have an example as small as possible

Taifun

Anwar Ahmed

unread,
Jun 6, 2016, 8:39:21 AM6/6/16
to MIT App Inventor Forum
I am using Thunkable.com, and when I contacted the authors of Thunkable, they found that the problem is on the slider and they said they will try to fix the problem ASAP. I am not sure if the same error is on MIT app inventor, but wanted to share. 

Taifun

unread,
Jun 6, 2016, 10:06:25 AM6/6/16
to MIT App Inventor Forum

Anwar Ahmed

unread,
Jun 6, 2016, 3:31:39 PM6/6/16
to MIT App Inventor Forum
I already attached the aia file, the problem is caused by the slider. I am using it to change the font size

Anwar Ahmed

unread,
Jun 6, 2016, 3:31:41 PM6/6/16
to MIT App Inventor Forum

Taifun

unread,
Jun 6, 2016, 5:48:37 PM6/6/16
to MIT App Inventor Forum
before setting the Fontsize use additionally the round block to make sure, that you are setting an integer value...


Taifun
Reply all
Reply to author
Forward
0 new messages