“Conversion to Dalvik format failed with error 1” on external JAR

前端 未结 30 2437
抹茶落季
抹茶落季 2020-11-21 07:32

In my Android application in Eclipse I get the following error.

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already add

相关标签:
30条回答
  • 2020-11-21 07:57

    Here's another scenario, and solution:

    If you run into this problem recently after updating the ADT for Eclipse:

    1. In your app project, check for any linked source folders pointing to your library projects (they have names in the form "LibraryName_src").
    2. Select all those projects, right-click, choose "Build Path"->"Remove from Build Path".
    3. Choose "Also unlink the folder from the project", and click "Yes".
    4. Clean, rebuild and redeploy the project.

    It seems the reason is that some previous version of ADT linked Library project source folders to the "child" projects, and the current ADT/Dex combination isn't compatible with that solution anymore.

    EDIT: this is confirmed by an Android Dev Blog entry, specifically this one - see the 8th paragraph onwards.

    0 讨论(0)
  • 2020-11-21 07:57

    For me, an extra JAR reference had appeared in my build path. I deleted this, and it works now.

    0 讨论(0)
  • 2020-11-21 07:58

    Go to Project » Properties » Java Build Path » Libraries and remove all except the "Android X.Y" (in my case Android 1.5). click OK. Go to Project » Clean » Clean projects selected below » select your project and click OK. That should work.

    It is also possible that you have a JAR file located somewhere in your project folders (I had copied the Admob JAR file into my src folder) and THEN added it as a Java Path Library. It does not show up under the Package Explorer, so you don't notice it, but it does get counted twice, causing the dreaded Dalvik error 1.

    Another possible reason could be package name conflicts. Suppose you have a package com.abc.xyz and a class named A.java inside this package, and another library project (which is added to the dependency of this project) which contains the same com.abc.xyz.A.java, then you will be getting the exact same error. This means, you have multiple references to the same file A.java and can't properly build it.

    In other ways this may be occurred if you accidentally or knowingly edit/ add any thing in the class path file manually .In certain cases we may add android.jar path manually to classpath file for generating java doc.On removing the that after javadoc generated code will works fine.Please check this too if any one still occurs.

    0 讨论(0)
  • 2020-11-21 08:00

    You can solve this issue easily (with Eclipse Android Developer Tools, Build: v22.0.1-685705) by turn off menu > "Project" > "Build Automatically" while exporting (un)signed Android application. After that, don't forget to turn it on again.

    0 讨论(0)
  • 2020-11-21 08:04

    My problem was caused by ADT version 12.0 and ProGuard integration. This bug is well documented and the solution is in the documentation

    Solution is in here

    ProGuard command line

    0 讨论(0)
  • 2020-11-21 08:04

    In my case the problem is actually with OpenFeint API project. I have added OpenFeint as library project:

    library project]![1]![Enter image description here.

    It is also added into build path, ADT tools 16 gives error with this sceneario.

    Right click on your project and click build path, configure the build path and then see the image and remove your project OpenFeint from here and all is done :)

    Enter image description here

    0 讨论(0)
提交回复
热议问题