2

I keep getting this error in Android Studio when I run my app on an Android phone. I have spent several weeks trying to fix it and have implemented the following measures:

  • Added android name to be

    android:name="android.support.multidex.MultiDexApplication"
    
  • Added source compatibility as follows:

    compileOptions
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    
  • Declared proguard +multidex file with list of extra classes

  • Made changes to root level gradle file by adding urls in the repositories and then changed the order of calling the repos

  • Updated android IDE and android studio, android sdk platform tools. gradle build files

  • Copied all the libraries from .idea/libs folder to GSDemo/apps/libs folder

  • Created a new libs folder in project root and copied all the libraries’ jar files into it

  • Disabled instant run

  • Moved the codes from java subfolder to src folder

  • Invalid cache/restart

Below is the error I get:

java.lang.NoClassDefFoundError: Failed resolution of:
Ldji/common/mission/waypoint/WaypointMissionFinishedAction;
at googlemap.gsdemo.dji.com.gsdemo.MainActivity.(MainActivity.java:81)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1086)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2843)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1646)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6836)
at java.lang.reflect.Method.invoke(Native Method)
Henry
  • 42,982
  • 7
  • 68
  • 84
  • 1
    Is this one of your classes that is missing? Have you tried to disable proguard completely (just it check if it is the cause)? – Henry Jul 16 '18 at 03:48

2 Answers2

0

NoClassDefFoundError: means your phone is running on a different version of android like 32bit or 64 bit you need to add jniLibs folder in the android project.

Search little bit more on jniLibs folder.

enter image description here

Jigar Fumakiya
  • 2,039
  • 1
  • 8
  • 21
  • Why do you think it is a native library that is missing? There is no sign of it in the stack trace. – Henry Jul 16 '18 at 09:15
  • NoClassDefFoundError indicates that, at runtime the class cannot be found. It can be the result of the class not being included as part of the output, being stripped because of Proguard rules or any other number of reasons (see article below). Yes, I agree it can also be that the native libraries for the device are missing but that seams to be way down the list of things to check IMHO. https://stackoverflow.com/questions/17973970/how-to-solve-java-lang-noclassdeffounderror – Kenneth Argo Jul 17 '18 at 03:22
0

It appears that either the SDK files are not being imported or are being removed because of the Proguard rules you are using.

The easiest way to include the SDK is to add the imports to your build.gradle as follows:

compile 'com.dji:dji-sdk:4.6'
provided 'com.dji:dji-sdk-provided:4.6'

You could try turning off Proguard for a test, if you don't get the exception it would point to the proguard rules.

Hopefully one of these will help.

Kenneth Argo
  • 1,697
  • 12
  • 19