简体   繁体   中英

Android java.lang.NoClassDefFoundError for class in my project

I am getting below error on initializing the NavigationDrawerRecyclerViewAdapter .

Now class com.mypackage.app.NavigationDrawerRecyclerViewAdapter exists and it is public and its constructor is public as well.

1: thread exiting with uncaught exception (group=0x416fed58)
05-18 10:46:20.573 3669-3669/com.mypackage.app E/AndroidRuntime: FATAL EXCEPTION: main Process: com.mypackage.app, PID: 3669
java.lang.NoClassDefFoundError: com.mypackage.app.NavigationDrawerRecyclerViewAdapter                                                                       at com.mypackage.app.FragmentDrawer.onCreateView(FragmentDrawer.java:68)

clean and rebuild project doesn't work. Any suggestions around what could be the problem here?

Click on your project -> Properties -> Build Path -> Order and Export Tab. Make sure that "Android Private Libraries" is checked for Export. If libraries are already adde from the libs/ folder, remove them as they are automatically added in the "Android Private Libraries" section.

NoClassDefFoundError indicates that class was present during the time of compilation but not available when you run your application, sometimes error on static initializer block can also result in NoClassDefFoundError or context of this class not accessible. So, make sure this class refers same class memory.

I found the answer.

I had multidex enabled and that was causing the problem. I was using compile 'com.google.android.gms:play-services:8.4.0' in my build.gradle while I needed only com.google.android.gms:play-services-auth:8.4.0.

Changing the above , I was able to run my application without enabling multidex which was causing class not found error.

This helped: App not launching with multidexEnabled true in android studio - Famous 65k reference method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM