Android Question Oops: java.lang.NoClassDefFoundError

Peter Simpson

Expert
Licensed User
Longtime User
Hiya all,
This just appeared in one of my apps on the Play Store. I'm using AppCompat from @corwin42 and this is the first error that I've seen, which isn't too bad really considering that I have a few thousand users using my apps.

Error is in Anywayandroid.support.v7.app.ActionBarActivityDelegateBase.initializePanelMenu and I'm not sure where to start with error, any ideas?

B4X:
java.lang.NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder
at android.support.v7.app.ActionBarActivityDelegateBase.initializePanelMenu(ActionBarActivityDelegateBase.java:914)
at android.support.v7.app.ActionBarActivityDelegateBase.preparePanel(ActionBarActivityDelegateBase.java:964)
at android.support.v7.app.ActionBarActivityDelegateBase.doInvalidatePanelMenu(ActionBarActivityDelegateBase.java:1182)
at android.support.v7.app.ActionBarActivityDelegateBase.access$100(ActionBarActivityDelegateBase.java:79)
at android.support.v7.app.ActionBarActivityDelegateBase$1.run(ActionBarActivityDelegateBase.java:115)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5285)
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)

Screenshot_2015-04-27-09-46-53.png
 

thedesolatesoul

Expert
Licensed User
Longtime User
Infact a huge number of developers are facing this issue and the only workaround seems to be to obsucate the appcompat-v7 menu builder class using proguard. Not quite sure how we can do that with B4A as I imagine this would happen at app compile stage. (or i guess library compile stage for the AppCompat library). Which is a shame as it forced us to obfuscate a library and makes debugging harder.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
First: AppCompat wrapper library works very well with the v22.1 version of the support library.

The above issue is an issue with Samsung (and at least Wiko) devices with Android 4.2.2. thedesolatesoul is absolutely correct.

The question is how to solve this. Seems that it can be easily solved with ProGuard (would be just a one liner) but I don't know if it can be used with the #CustomBuildAction attribute. maybe @Erel can say something about it. I have absolutely no experiance with ProGuard.

Does anybody here has an affected device to do some tests? I'm not sure if this solution will work. This would be easy to add to the wrapper library but I need a device to test it on. Seems that it happens when you set a ToolBar as ActionBar.
 
Upvote 0

corwin42

Expert
Licensed User
Longtime User
A workaround to this issue may be:

B4X:
Try
    ToolBar.SetAsActionBar
Catch
    Log("Faulty Samsung ROM?")
End Try
 
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Did you update your SDK?
If yes; maybe this is the problem. AppCombat has been xtended. Maybe you need a new version of AppCompat library
My SDK had is uptodate @DonManfred.

Dont update your SDK yet as it requires an AppCompat library update.
Your problem seems to be actually due to Samsungs 4.2.2 devices:
http://stackoverflow.com/questions/...oid-support-v7-internal-view-menu-menubuilder
Hmm, I'm now lost.

Infact a huge number of developers are facing this issue and the only workaround seems to be to obsucate the appcompat-v7 menu builder class using proguard. Not quite sure how we can do that with B4A as I imagine this would happen at app compile stage. (or i guess library compile stage for the AppCompat library). Which is a shame as it forced us to obfuscate a library and makes debugging harder.

Thank you @thedesolatesoul I will read this :)

A workaround to this issue may be:

B4X:
Try
    ToolBar.SetAsActionBar
Catch
    Log("Faulty Samsung ROM?")
End Try
Thank you @corwin42, I'll give it a try :D.

The thing that baffles me is that I have an Samsung S4 test device with Android 4.2.2 and it works perfect on that device. I have turned off the auto update OS as I need a Samsung phone with 4.2.2 and it's been trying to install Android 5.x...


Thanks to everybody for helping me with this issue, what a great community this is :cool:
 
Last edited:
Upvote 0
Top