The question:

There is an issue with the Android appcompat v7 library on Samsung devices running Android 4.2. I keep getting crashes with the following stack trace in my Developer Console:

    at com.[my-package-name].CustomActivity$5.onClick(
    at android.view.View.performClick(
    at android.view.View$
    at android.os.Handler.handleCallback(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(
    at dalvik.system.NativeStart.main(Native Method)

This is line 215 of

PopupMenu popup = new PopupMenu(CustomActivity.this, mImageViewMenu);

The crashes come from an array of devices, but always Samsung, and always Android 4.2.

A quick web search leads me to believe that many people have the same issue, some of the steps I have tried to solve the issue are:

  • Check the Android project properties, make sure the appcompat library is added properly.
  • Check the Java Build Path Order and Export project properties, make sure Android Dependencies and Android Private Libraries is checked.
  • Confirm the class is included in the library (
  • Confirm is located in gen directory for
  • Confirm the AppCompat theme is included in the Manifest.xml activity.
  • Clean and rebuild project.

Despite these steps, and despite it working on all other devices and Android versions the crash reports still come through.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1


The solution that worked for me was (Using Proguard) to replace this:

-keep class** { *; } 
-keep interface** { *; }

-keep class** { *; }
-keep interface** { *; }

with this:

# Allow obfuscation of**
# to avoid problem on Samsung 4.2.2 devices with appcompat v21
# see
-keep class !**,** {*;}

Credit goes to the google group, #138.

Old answer (Temporary Workaround):
It happens in a project where I use an spinner in the ActionBar. My solution was to check for those conditions and change the 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 the activity’s onCreate method:

if (isSamsung_4_2_2()) {
} else {

As pointed out this is not a definitive solution, it is just a way to allow users to have access to limited functionality while a more permanent solution is found.

Method 2

As #150 from google groups said

Because careful with -keep class
!**. There are a number of
classes in there which are referenced from the appcompat’s resources.

The better solution is add the following lines instead:

-keep class !*MenuBuilder*,** { *; }
-keep interface** { *; }

Method 3

On which device you are facing this problem ? (Samsung/HTC etc.)

If it is Samsung,

Various Samsung phones are included older versions of the android support library in the framework or classpath. If you use the new material support library, you’ll see this crash on those Samsung devices:


To fix this, you must rename that class. Easiest way to do that is by running proguard. If you don’t want to obfuscate, here’s a 1 liner to rename just the offending classes:

-keep class !**,** {*;}

There’s an issue tracking this problem, but since it’s really a Samsung bug, it’s never going to get fixed on their end. Only way to fix it on the Google/AOSP side is to rename these internal classes.

Method 4

This issue returned in AppCompat 23.1.1 where the .internal package was removed from the library jar.

As suggested in the comments above (credits to the people who suggested it there), now also the proguard configuration has to change.

To get the answer suggested above working again, try adding these lines to your proguard files:

-keep class !*MenuBuilder*,** { *; }
-keep interface* { *; }

In stead of the old fix:

-keep class !*MenuBuilder,** { ; }
-keep interface* { *; }

Method 5

According to the last posts of the bug-report, this should be fixed on the new version of the support library (24.0.0) :

Someone even claimed it fixed it.

This version is available since last month, so you should update to it.

Method 6

Yes. Samsung already knows about this problem.
I can suggest you try to using same implementation of Popup from GitHub. It is not best way, but will be works.

Method 7

I was having the same problem of this MenuBuilder class not found in USB debugging mode. I solved this problem by simply setting the minifyEnabled to true in both release and debug buildTypes block of build.gradle . like this:

buildTypes {

    debug {

        minifyEnabled true

    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

I set the minifyEnabled to true in debug type to prevent app from crashing via USB debugging to a live handset.

Method 8

I enabled proguard with the default proguard properties provided with an eclipse project and the problem was fixed for me. Based on some comments here , some people might have to repackage using:
-repackageclasses “”

Method 9

I got the same error when trying to run a ‘Hello World’ app on my Samsung Galaxy Tab 3 tablet via Android Studio. The app would appear to launch and then it would crash instantly and that error would show in the console in Android Studio. I did a system update on the tablet and now I am able to run the ‘Hello World’ app and I’m not getting the error anymore. I hope this helps someone to resolve their issue.

Note: The system update I performed on the tablet did not update the Android OS version, because it still says that the version is 4.2.2.

Method 10

Change the Compile Sdk Version of your project to “API 18:(JellyBean)”

The default is set to “Lollipop


  1. Right Click on your project and select Open Module Settings (or press F4)
  2. In the properties tab Compiled Sdk Version

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment