java - NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder -
there issue android appcompat v7 library on samsung devices running android 4.2. keep getting crashes following stack trace in developer console:
java.lang.noclassdeffounderror: android.support.v7.internal.view.menu.menubuilder @ android.support.v7.widget.popupmenu.<init>(popupmenu.java:66) @ com.[my-package-name].customactivity$5.onclick(customactivity.java:215) @ android.view.view.performclick(view.java:4222) @ android.view.view$performclick.run(view.java:17620) @ android.os.handler.handlecallback(handler.java:800) @ android.os.handler.dispatchmessage(handler.java:100) @ android.os.looper.loop(looper.java:194) @ android.app.activitythread.main(activitythread.java:5391) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:833) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) @ dalvik.system.nativestart.main(native method)
this line 215 of customactivity.java:
popupmenu popup = new popupmenu(customactivity.this, mimageviewmenu);
the crashes come array of devices, samsung, , android 4.2.
a quick web search leads me believe many people have same issue, of steps have tried solve issue are:
- check android project properties, make sure appcompat library added properly.
- check java build path order , export project properties, make sure android dependencies , android private libraries checked.
- confirm class included in library (android.support.v7.internal.view.menu.menubuilder).
- confirm r.java located in gen directory android.support.v7.appcompat.
- confirm appcompat theme included in manifest.xml activity.
- clean , rebuild project.
despite these steps, , despite working on other devices , android versions crash reports still come through.
edit:
the solution worked me (using proguard) replace this:
-keep class android.support.v4.** { *; } -keep interface android.support.v4.** { *; } -keep class android.support.v7.** { *; } -keep interface android.support.v7.** { *; }
with this:
# allow obfuscation of android.support.v7.internal.view.menu.** # avoid problem on samsung 4.2.2 devices appcompat v21 # see https://code.google.com/p/android/issues/detail?id=78377 -keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
credit goes google group, #138.
old answer (temporary workaround): happens in project use spinner in the actionbar. solution check conditions , change app flow:
public static boolean issamsung_4_2_2() { string deviceman = build.manufacturer; string devicerel = build.version.release; return "samsung".equalsignorecase(deviceman) && devicerel.startswith("4.2.2"); }
then in activity's oncreate method:
if (issamsung_4_2_2()) { setcontentview(r.layout.activity_main_no_toolbar); } else { setcontentview(r.layout.activity_main); }
as pointed out not definitive solution, way allow users have access limited functionality while more permanent solution found.
Comments
Post a Comment