3

I'm testing my project on MotoG (Lollipop 5.1) and a have problem that didn't have on XperiaT2 (KitKat 4.4). The error log is:

 java.lang.NoClassDefFoundError: android.support.design.internal.NavigationMenuItemView
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:309)

I'm using android.support:design library but not instanciate the NavigationView, I tried to use

compile 'com.android.support:design:22.2.1'

and

compile 'com.android.support:design:23.1.1'

And didn't solve. Maybe the problem is related with a previously problem with support:appcompat library that this error happened when I tried use a 23.1.1 lower version

NoClassDefFoundError: android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23$1

My actual Gradle configuration is:

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 21
    }
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'

Please some help.

UPDATE

When I try to use

buildToolsVersion '23.0.2'
'com.android.support:appcompat-v7:23.1.1'
'com.android.support:design:23.1.1'

I have error to render the preview on android studio

Exception Details java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.

Even using my theme this way

<style name="MyTheme" parent="Theme.AppCompat.Light">
7xRobin
  • 341
  • 1
  • 4
  • 11
  • Did you try with buildToolsVersion '23.0.2' and compile 'com.android.support:design:23.1.1'? – LordCommanDev Dec 17 '15 at 13:56
  • @Coeus I tried and appears this error again: NoClassDefFoundError: android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23$1 – 7xRobin Dec 17 '15 at 16:30

2 Answers2

1

Maybe you could try the following code and try again:

./gradlew clean

Or this:

gradle clean

According to some links I search around, may these do some tricks for you.

Anthonyeef
  • 2,595
  • 1
  • 27
  • 25
0

Try a solution (I've added below) from: NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder

EDIT:

The solution that worked for me was (Using Proguard) to 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.**
# to avoid problem on Samsung 4.2.2 devices with 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 to the google group: https://code.google.com/p/android/issues/detail?id=78377 #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()) {
    setContentView(R.layout.activity_main_no_toolbar);
} else {
    setContentView(R.layout.activity_main);
}

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.

It seems to be a similar problem, so try it out and let me know if it works

EDIT: According to this Gihub issue, https://github.com/JoanZapata/android-iconify/issues/93 where you find this clue:

There is no error when I am using com.android.support:design:22.2.0

The error only occurs when I am using com.android.support:design:22.2.1

Downgrade you build-tools to 22.2.0 - it may be an Android problem.

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • Note: try to delete ProGuard. It's already deprecated by Google – piotrek1543 Dec 17 '15 at 15:04
  • I tried use -keep class on Proguard still didn't work. – 7xRobin Dec 17 '15 at 16:21
  • I don't understand your comment it's really for to delete Proguard? How do this? – 7xRobin Dec 17 '15 at 16:22
  • #robindesu, please add your xml file – piotrek1543 Dec 17 '15 at 21:35
  • 1
    What xml do you mean? How a said I don't use NavigationView in fact. I can post the xml of main activity if help. – 7xRobin Dec 22 '15 at 12:27
  • ok, nothing there. Look at your `build.gradle`. there are four libs with name starting with `com.android.support`. change all them version to one specific like `22.2.0` – piotrek1543 Jan 04 '16 at 12:59
  • try with version `23.01` - apply to every of these four dependencies – piotrek1543 Jan 05 '16 at 18:09
  • Didn't work. I guess that the problem It's some incompatibility between appcompat and design libraries. When I used 23 version of design, appears a error for to handle the preview (Exception Details java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.). Even using parent="Theme.AppCompat.Light" on my theme. – 7xRobin Jan 05 '16 at 18:26