1

There are multiple questions that address this problem.. but none have worked for me..

I am using two libraries Jazzy view pager and mpAndroidChartLibrary The jazzyViewPager is a library project wheras androidChartLibrary is a jar File

I am getting the following error when I try to run the project

[2015-03-03 11:27:02 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
[2015-03-03 11:27:02 - chart] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;

I have repeatedly cleaned the project and restarted eclipse and the system.. But still the error remains

According to suggestions I did the following

  • Right click on the Project Name
  • Select Build Path -> Configure Build Path
  • In Java Build Path, go to the tab Order and Export
  • Uncheck Android Private Libraries

after this the app runs.. but then the following dalvikvm exception occurs

 Unable to resolve superclass of Lcom/example/chart/MainActivity; (30)
 Link of class 'Lcom/example/chart/MainActivity;' failed
 threadid=1: thread exiting with uncaught exception (group=0x40e19540)

afterwards a Class not found exception occurs ..

  java.lang.RuntimeException: Unable to instantiate activity ComponentInfo 
 {com.example.chart/com.example.chart.MainActivity}: 
 java.lang.ClassNotFoundException: com.example.chart.MainActivity

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2271)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
    at android.app.ActivityThread.access$600(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:155)
    at android.app.ActivityThread.main(ActivityThread.java:5520)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
    at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.ClassNotFoundException: com.example.chart.MainActivity
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1069)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
    ... 11 more

My manifest is correct.. that used to work b4 adding the chart jar.. and it works when i remove it..

Alvin
  • 416
  • 1
  • 8
  • 18
  • You include `nineoldandroids` twice. – Wesley Mar 03 '15 at 06:10
  • @Wesley where?? i didnt get you.. – Alvin Mar 03 '15 at 06:11
  • Are `Jazzy view pager` and `mpAndroidChartLibrary` are the only two libraries you are using in your project? Did `Jazzy view pager` or `mpAndroidChartLibrary` use the library `nineoldandroids`? If so, you should exclude it. – Wesley Mar 03 '15 at 06:14
  • @Wesley there is a nineoldandroids 2.4.0.jar in the private libraries alongside mpAndroidChartLibrary .jar and supportv4 , supportv7 other than that in the libraries there is mpAndroidChartLibrary .jar along with supportv4 – Alvin Mar 03 '15 at 06:17
  • @Wesley YES THEY ARE .. and both are nineoldandroids.. so how do i exclude them>??? – Alvin Mar 03 '15 at 06:20
  • Try remove `nineoldandroids` dependency. The error you got (`Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;`) means that there are more than one kind of this class, so Dalvik doesn't know which one to choose. – Wesley Mar 03 '15 at 06:21
  • If you are using Eclipse, try use `maven` to manage your dependencies, and it's easy to exclude one dependency out of a library when using maven. I don't know how to exclude a dependency out of a library purely using Eclipse. Sorry. – Wesley Mar 03 '15 at 06:25
  • @Wesley ok .. can u tell me how to remove the dependency using maven??? – Alvin Mar 03 '15 at 07:37
  • In maven, try something like this: ``` com.google.android android 4.1.1.4 provided commons-logging commons-logging ``` – Wesley Mar 03 '15 at 07:42
  • @Wesley hi me once again, the project wont accept the library now.. and even when i turn it back the project cant recognize the library.. . Resource Path Location Type JazzyViewPager cannot be resolved to a type – Alvin Mar 03 '15 at 08:47
  • Try 'multiDexEnabled true` in your build.gradle file and extend your app class instance from `MultiDexApplication` instead `Application`. – theapache64 Jan 23 '18 at 12:11

1 Answers1

0

Incase you have tried the other methods of making sure you do not have any different conflicting versions of libraries in your build.gradle and it still hasn't worked for you, it means "nineoldandroids" library is a huge library that contains other invisible smaller libraries which are conflicting with dependencies in your other modules to cause this problem..

This is how to solve it..

  1. Identify the build.gradle which contains "nineoldandroids" library..
  2. Change it to "compileOnly files" ..

  3. Clean and rebuild the project...

This will prevent it from leaking dependencies to other modules in your project, thereby stopping these invisible conflicts...

Samuel Ewudzi Incoom
  • 1,802
  • 17
  • 17