“转换到Dalvik格式错误1”外部JAR。

时间:2022-12-17 09:15:30

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

在Eclipse的Android应用程序中,我得到了以下错误。

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/xmlpull/v1/XmlPullParser;
....
Conversion to Dalvik format failed with error 1

意想不到的*例外:. lang。IllegalArgumentException:已补充道:Lorg xmlpull / v1 / XmlPullParser;....转换到Dalvik格式错误1。

This error only appears when I add a specific external JAR file to my project. I searched for a long time for the possible solution, but none of the possible solutions work. I even tried to change to Android 1.6 instead of 1.5 (the current version I use).

当我在我的项目中添加一个特定的外部JAR文件时,这个错误才会出现。我搜索了很长时间寻找可能的解决方案,但是没有一个可行的解决方案。我甚至尝试改用Android 1.6,而不是1.5(我现在使用的版本)。

71 个解决方案

#1


821  

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.

转到项目»属性»Java构建路径»库并删除除“Android X”之外的所有内容。(在我的例子中是Android 1.5)。单击OK。去项目»清洁»在下面选择的清洁项目»选择你的项目并点击确定。这应该工作。

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.

也有可能您的项目文件夹中的某个地方有一个JAR文件(我已经将Admob JAR文件复制到我的src文件夹中),然后将其添加为Java路径库。它不会出现在Package Explorer下,所以您不会注意到它,但是它会被计算两次,导致可怕的Dalvik错误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.

另一个可能的原因可能是包名冲突。假设你有一个包裹。xyz和一个名为a的类。这个包中的java和另一个库项目(该项目被添加到这个项目的依赖项中)包含相同的com. abc.xyza。java,你会得到完全相同的错误。这意味着,您对同一个文件A有多个引用。java并不能正确地构建它。

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.

在其他方面,如果您不小心或有意地在类路径文件中手动编辑/添加任何东西,可能会发生这种情况。在某些情况下,我们可能会添加android。用于生成java doc的类路径文件的jar路径。在删除javadoc生成的代码之后,将会运行良好。如果还有的话,请检查一下。

#2


270  

I solved the problem.

我解决了这个问题。

This is a JAR file conflict.

这是一个JAR文件冲突。

It seems that I have two JAR files on my buildpath that include the same package and classes.

似乎我的buildpath上有两个JAR文件,其中包含相同的包和类。

smack.jar and android_maps_lib-1.0.2

打。jar和android_maps_lib-1.0.2

Deleting this package from one of the JAR files solved the problem.

从一个JAR文件中删除这个包可以解决这个问题。

#3


125  

Windows 7 Solution:

Windows 7的解决方案:

Confirmed the problem is caused by ProGuard command line in the file
[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat

确认问题是由ProGuard命令行在文件[Android SDK安装目录]\tools\ ProGuard \bin\proguard.bat中引起的。

Edit the following line will solve the problem:

编辑下一行将解决问题:

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*

to

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

#4


94  

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.

您可以轻松地解决这个问题(使用Eclipse Android开发工具,构建:v22.0.1-685705),在导出(un)签名的Android应用程序时,关闭菜单>“项目”>“自动构建”。在那之后,别忘了把它打开。

#5


53  

If you have ADT revision 12+, you should update your proguard from 4.4 -> 4.6 (as described here). Also, you should leave ...\bin\proguard.bat file in the orginal form.

如果您有ADT修订12+,您应该从4.4 -> 4.6(这里描述的)更新您的proguard。此外,你应该离开…\bin\proguard。在组织形式的bat文件。

Just download it from the web, and copy lib folder from downloaded package to the :

只需从网上下载,并从下载的包复制lib文件夹到:

[Android SDK Installation Directory]\tools\proguard\lib

(Android SDK安装目录)\ \混淆器\ lib工具

#6


40  

EDIT (new solution):

编辑(新解决方案):

It looks like the previous solution is only a bypass. I managed to finally fix the problem permanently: In my case there was a mismatch in android-support-v4 files in my project and in the Facebook project that is referenced in my project.

看起来之前的解决方案只是一个旁路。我最终成功地解决了这个问题:在我的案例中,我的项目和项目中引用的Facebook项目中的android-support-v4文件不匹配。

I found this error by performing Lint Check (Android Tools / Run Lint: Check for Common Errors)

我通过执行Lint检查发现了这个错误(Android工具/运行Lint:检查常见错误)

My previous solution:

我以前的解决方案:

I've tried any possible solution on this site - nothing helped!!!

我在这个网站上尝试了任何可能的解决方案-没有任何帮助!!!

Finally I've found an answer here: https://groups.google.com/forum/#!topic/actionbarsherlock/drzI7pEvKd4

最后,我在这里找到了一个答案:https://groups.google.com/forum/#!

Easy steps:

简单的步骤:

Go to Project -> uncheck Build Automatically

去项目->取消自动构建。

Go to Project -> Clean... , clean both the library project and your app project

去项目->清洁…,清理图书馆项目和你的应用项目。

Export your app as a signed APK while Build Automatically is still disabled

在自动构建时,将应用程序导出为已签名的APK。

#7


30  

Here's another scenario, and solution:

下面是另一个场景和解决方案:

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

如果您在更新了Eclipse ADT之后最近遇到了这个问题:

  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. 在您的应用程序项目中,检查指向您的库项目的任何链接源文件夹(它们在表单“LibraryName_src”中有名称)。
  3. Select all those projects, right-click, choose "Build Path"->"Remove from Build Path".
  4. 选择所有这些项目,右键单击,选择“构建路径”->“从构建路径中移除”。
  5. Choose "Also unlink the folder from the project", and click "Yes".
  6. 选择“也断开项目的文件夹”,点击“是”。
  7. Clean, rebuild and redeploy the project.
  8. 清理、重建和重新部署项目。

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.

似乎原因是一些以前版本的ADT链接库项目源文件夹到“子”项目,而当前的ADT/Dex组合与那个解决方案不兼容。

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

编辑:这是通过一个Android开发博客的条目来确认的,具体来说就是这个——看第8段。

#8


29  

Go to Project and then uncheck "Build Automatically".Then try to export the project and the error is gone.

进入项目,然后取消“自动构建”。然后尝试导出项目,错误就消失了。

#9


26  

This can also be caused if you have added Android.jar file to your build path, perhaps by an accidental quick fix in Eclipse. Remove it with right clicking Project -> build path -> configure build path -> android.jar, remove.

如果你添加了Android,也会造成这种情况。jar文件到您的构建路径,可能是在Eclipse中偶然的快速修复。使用右击项目->构建路径->配置构建路径-> android。jar、删除。

#10


25  

Simply cleaning the project has worked for me every time this error has come up.

每次这个错误出现时,简单地清理这个项目就对我有效了。

#11


16  

My own and only solution that I found today after four hours of testing all the solutions, is a combination of many solutions provided here:

我自己的和唯一的解决方案,我今天在四个小时的测试所有的解决方案,是一个组合的许多解决方案在这里提供:

  • Delete project from Eclipse
  • 删除从Eclipse项目
  • Delete files in \bin and \gen from project folder
  • 从项目文件夹中删除\bin和\gen的文件。
  • Remove references to libraries into .classpath file in root project folder
  • 将对库的引用删除到根项目文件夹中的.classpath文件中。
  • Restart Eclipse with command line : eclipse -clean
  • 使用命令行重新启动Eclipse: Eclipse -clean。
  • Import project
  • 导入项目
  • Right click on project - select Properties > Java Build Path > Libraries and remove everything else than Android XX.Y
  • 右键点击项目-选择属性> Java构建路径>库,删除所有其他的东西,而不是Android XX.Y。
  • Finally clean project, wait for automatic Building or Build it
  • 最后清理项目,等待自动建立或建造。
  • Launch and now it works! At least for me...
  • 发射,现在成功了!至少对我来说……

I tried every step at a time and many combinations, but only the succession of all steps at once made it! I hope I won't face this again...

我尝试了每一步的每一步和许多组合,但只有所有步骤的演替立刻成功了!我希望我不会再面对这个……

#12


14  

Just for the other people who still have this problem and they have tried the above answers but still getting the error (which was my case), then my solution was to delete the project from Eclipse and re-import it again.

对于仍然存在这个问题的其他人,他们已经尝试了上面的答案,但是仍然得到了错误(这是我的情况),然后我的解决方案是从Eclipse中删除项目并再次导入它。

This made the Android library to be added again to my referenced libraries, so now I have two Android JAR files referenced, hence I deleted one of them and now it compiles fine.

这使得Android库再次被添加到我的引用库中,所以现在我有两个Android JAR文件被引用,因此我删除了其中一个,现在它可以编译了。

Solution: Delete the project from Eclipse IDE and then re-import it again, then check for the above solutions.

解决方案:从Eclipse IDE中删除项目,然后再重新导入它,然后检查上面的解决方案。

#13


10  

Ran into this problem myself today. Cleaning and rebuild did not fix the problem. Deleting and reimporting the project didn't help either.

今天我自己遇到了这个问题。清理和重建并没有解决问题。删除和重新导入项目也没有帮助。

I finally traced it back to a bad additions to my .class file. I think this was added by the plugin tools when I was trying to fix another problem, removing it got rid of the "Conversion to Dalvik format failed with error 1" build error:

最后,我将它追溯到我的.class文件的一个不好的添加。我想,当我试图修复另一个问题时,插件工具添加了这个功能,删除了它,去掉了“对Dalvik格式的转换失败的错误1”构建错误:

<classpathentry kind="lib" path="C:/dev/repository/android-sdk-windows/platforms/android-3/android.jar">
    <attributes>
        <attribute name="javadoc_location" value="file:/C:/dev/repository/android-sdk-windows/docs/reference"/>
    </attributes>
    <accessrules>
        <accessrule kind="nonaccessible" pattern="com/android/internal/**"/>
    </accessrules>

#14


9  

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

对我来说,在我的构建路径中出现了一个额外的JAR引用。我删除了这个,它现在起作用了。

#15


8  

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

我的问题是由ADT版本12.0和ProGuard集成引起的。这个bug有很好的文档记录,解决方案也在文档中。

Solution is in here

解决方案是在这里

ProGuard command line

混淆器命令行

#16


8  

I've dealt with this problem when using Sherlock ActionBar library in my project. You could do the following step, it's work for me.

在我的项目中使用Sherlock ActionBar库时,我已经解决了这个问题。你可以做下面的步骤,这对我很有效。

  1. Right click to your project, select properties.
  2. 右键单击您的项目,选择properties。
  3. A dialog will show up, select 'Java build path' on the left menu.
  4. 将出现一个对话框,在左侧菜单中选择“Java构建路径”。
  5. Remove 'Android dependencies' and 'Android private libraries' on the right panel then click OK
  6. 在右面板上删除“Android依赖项”和“Android专用库”,然后单击“确定”。
  7. Clean your project (select menu Project --> Clean)
  8. 清理你的项目(选择菜单项目——> Clean)
  9. Right click your project, select Android Tools -> Fix project properties
  10. 右键单击项目,选择Android Tools ->修复项目属性。
  11. Clean project once again.
  12. 再次清洁项目。
  13. Restart your computer
  14. 重新启动你的电脑
  15. Open eclipse and Export apk
  16. 打开eclipse并导出apk。

Hope that will help you.

希望能帮到你。

#17


7  

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

在我的例子中,问题在于OpenFeint API项目。我增加了OpenFeint作为图书馆项目:

“转换到Dalvik格式错误1”外部JAR。.

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

它也被添加到构建路径中,ADT工具16给出了这个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 :)

右键单击您的项目并单击build path,配置构建路径,然后查看该映像并从这里删除您的项目OpenFeint,然后全部完成:)

“转换到Dalvik格式错误1”外部JAR。

#18


7  

I found something else. Android uses the /libs directory for JAR files. I have seen the "Conversion to Dalvik format failed with error 1" error numerous times, always when I made a mistake in my JAR files.

我发现别的东西。Android为JAR文件使用/libs目录。我曾多次看到“转换为Dalvik格式错误1”错误,总是在我的JAR文件中出错。

Now I upgraded Roboguice to a newer version, by putting the new JAR file in the /libs directory and switching the class path to the new version. That caused the Dalvik error.

现在,我将Roboguice升级到一个新的版本,将新的JAR文件放入/libs目录中,并将类路径切换到新版本。这导致了Dalvik错误。

When I removed one of the Roboguice JAR files from the /libs folder, the error disappeared. Apparently, Android picks up all JAR files from /libs, regardless of which ones you specify in the Java build path. I don't remember exactly, but I think Android started using /libs by default starting with Android 4.0 (Ice Cream Sandwich, ICS).

当我从/libs文件夹中删除了一个Roboguice JAR文件时,错误就消失了。显然,Android会从/libs中获取所有JAR文件,不管您在Java构建路径中指定了哪些文件。我不太记得了,但我认为Android从默认开始使用/libs开始使用安卓4.0(冰淇淋三明治,ICS)。

#19


7  

Updating Proguard to latest version solved it for me.

更新Proguard到最新版本为我解决了它。

  • My proguard path was C:\Program Files (x86)\Android\android-sdk\tools\proguard\
  • 我的混淆器路径C:\Program Files (x86)\Android\ android sdk \混淆器\ \工具
  • I downloaded the new version from here
  • 我从这里下载了新版本。
  • and replaced both bin and lib folders
  • 并替换了bin和lib文件夹。

THANK GOD!

感谢上帝!

#20


7  

In general, it seems that this problem comes when there are unnecessary JAR files in build path.

一般来说,当构建路径中有不必要的JAR文件时,这个问题就会出现。

I faced this problem while working on IntelliJ IDEA. For me it happened because I added JUnit and Mockito libraries which were being compiled at runtime. This needed to be set to "testing" in module properties.

我在处理IntelliJ IDEA的时候遇到了这个问题。对我来说,这是因为我在运行时添加了JUnit和Mockito库。这需要在模块属性中进行“测试”。

#21


6  

None of previously proposed solutions worked for me. In my case, the problem happened when I switched from referencing a library source code folder to using the library JAR file. Initially there was an Android library project listed under the Android application project Properties\ Android page\ Library section, and the library compared also in project explorer tree as a link to the library source directory.

之前没有一个解决方案对我有效。在我的例子中,当我从引用一个库源代码文件夹切换到使用library JAR文件时,问题就发生了。最初在Android应用程序项目属性\ Android page\ library部分中列出了一个Android库项目,并且在project explorer树中作为一个链接到库源目录。

In the first place, I just deleted the directory link from the project tree and I added the JAR library to the build path, but this caused the exception.

首先,我只是从项目树中删除了目录链接,然后将JAR库添加到构建路径中,但这导致了异常。

The correct procedure was (after changing back the build path and putting back the reference to the library source):

正确的步骤是(在更改了构建路径后,将引用返回到库源):

  • properly remove the library source directory link by actually removing the reference from application project Properties\ Android page

    通过实际删除应用程序项目属性(Android)页面中的引用,适当地删除库源目录链接。

  • adding the library JAR to the application project build path as usual.

    像往常一样将库JAR添加到应用程序项目构建路径中。

#22


6  

None of the listed solutions worked for me.

所有列出的解决方案都不适合我。

Here's where I was having a problem:

我的问题是:

I added the jSoup external JAR file to my project's path by first putting it in a source folder called "libs", and then right clicking on it, Build Path -> add to build path. This threw the Dalvik conversion error. It said I had "already included" a class from that JAR file. I looked around the project's directory and found that the place where it was "already included" was in fact the bin directory. I deleted the JAR file from the bin directory and refreshed the project in Eclipse and the error went away!

我将jSoup外部JAR文件添加到项目的路径中,首先将它放入一个名为“libs”的源文件夹中,然后右键单击它,构建路径->添加到构建路径。这就抛出了Dalvik转换错误。它说我已经“包含”了一个来自JAR文件的类。我查看了这个项目的目录,发现它“已经包含”的地方实际上是bin目录。我从bin目录中删除了JAR文件,并在Eclipse中刷新项目,错误就消失了!

#23


5  

All the solutions above didn't work for me. I'm not using any precompiled .jar. I'm using the LVL and the Dalvik errors where all related to the market licensing library.

以上所有的解决方案对我都不起作用。我没有使用任何预编译的.jar。我使用的是LVL和Dalvik错误,这些错误都与市场许可库相关。

The problem got solved by deleting the main project and reimporting (create a new project from existing sources).

通过删除主项目和重新导入(从现有源创建一个新项目)来解决这个问题。

#24


5  

I had the same problem and none of these solutions worked. Finally, I saw in the console that the error was due to duplicated class (one in the existing project, one in the added jar file) :

我遇到了同样的问题,这些解决方案都没有奏效。最后,我在控制台看到了错误是由于重复的类(一个在现有的项目中,一个在添加的jar文件中):

java.lang.IllegalArgumentException: already added: package/MyClassclass;
[2011-01-19 14:54:05 - ...]: Dx1 error; aborting
[2011-01-19 14:54:05 - ...] Conversion to Dalvik format failed with error 1

So check if you are adding jar with duplicated classes in your project. If yes, try removing one of them.

因此,检查您是否在项目中添加了重复类的jar。如果是,请尝试删除其中一个。

It worked for me.

它为我工作。

#25


5  

Often for me, cleaning the project DOES NOT fix this problem.

通常对我来说,清理项目并不能解决这个问题。

But closing the project in Eclipse and then re-opening it does seem to fix it in those cases...

但是在Eclipse中关闭项目,然后重新打开,似乎在这些情况下修复了它……

#26


5  

I ran into this problem but my solution was twofold. 1.) I had to add an Android target version under project -> properties -> Android. 2.) I didn't have all google 'third party add-ons'. Click in AVD SDK manager under available packages -> third-party add-ons -> Google Inc. I downloaded all of the SDKs and that solved my issue.

我遇到了这个问题,但我的解决方法是双重的。1)。我必须在project ->属性-> Android上添加一个Android目标版本。我没有谷歌的第三方插件。在现有的软件包->第三方插件->谷歌Inc.下点击AVD SDK管理器,我下载了所有的SDK,解决了我的问题。

#27


5  

I am using Android 1.6 and had one external JAR file. What worked for me was to remove all libraries, right-click project and select Android Tools -> *Fix Project Properties (which added back Android 1.6) and then add back the external JAR file.

我使用的是Android 1.6,并且有一个外部JAR文件。为我工作的是删除所有的库,右键单击项目并选择Android工具-> *修复项目属性(添加了Android 1.6),然后添加外部JAR文件。

#28


5  

I ran into this problem because the Android-Maven-plugin in Eclipse was apparently not recognizing transitive references and references referenced twice from a couple of projects (including an Android library project), and including them more than once. I had to use hocus-pocus to get everything included only once, even though Maven is supposed to take care of all this.

我遇到了这个问题,因为Eclipse中的Android- maven -plugin显然不承认两个项目(包括一个Android库项目)所引用的可传递引用和引用,而且包含不止一次。我必须使用hocus-pocus才能得到所有的东西,即使Maven应该负责所有这些。

For example, I had a core library globalmentor-core, that was also used by globalmentor-google and globalmentor-android (the latter of which is an Android library). In the globalmentor-android pom.xml I had to mark the dependency as "provided" as well as excluded from other libraries in which it was transitively included:

例如,我有一个核心的图书馆globalmentor-core,它也被globalmentor-google和globalmentor-android(后者是一个Android图书馆)使用。globalmentor-android pom。我必须将依赖项标记为“提供”,并将其从其他库中排除,包括:

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-core</artifactId>
        <version>1.0-SNAPSHOT</version>
        <!-- android-maven-plugin can't seem to automatically keep this from being
             included twice; it must therefore be included manually (either explicitly
             or transitively) in dependent projects -->
        <scope>provided</scope>
    </dependency>

Then in the final application pom.xml I had to use the right trickery to allow only one inclusion path---as well as not explicitly including the core library:

然后在最后的应用程序pom中。我必须使用正确的欺骗手段只允许一个包含路径——以及不显式地包括核心库:

    <!-- android-maven-plugin can't seem to automatically keep this from being
        included twice -->
    <!-- <dependency> -->
    <!-- <groupId>com.globalmentor</groupId> -->
    <!-- <artifactId>globalmentor-core</artifactId> -->
    <!-- <version>1.0-SNAPSHOT</version> -->
    <!-- </dependency> -->

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-google</artifactId>
        <version>1.0-SNAPSHOT</version>
        <exclusions>
            <!-- android-maven-plugin can't seem to automatically keep this from
                being included twice -->
            <exclusion>
                <groupId>com.globalmentor</groupId>
                <artifactId>globalmentor-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-android</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

#29


5  

In my case

在我的例子中

project->properties->java build path -> in order and export tab -> uncheck android-support-v4.jar

项目->属性->java构建路径->在order和export标签-> uncheck android-support-v4.jar。

#30


5  

Just clean the project

清洁项目

If this does not work try the other solutions

如果这不是工作,尝试其他的解决方案。

#1


821  

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.

转到项目»属性»Java构建路径»库并删除除“Android X”之外的所有内容。(在我的例子中是Android 1.5)。单击OK。去项目»清洁»在下面选择的清洁项目»选择你的项目并点击确定。这应该工作。

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.

也有可能您的项目文件夹中的某个地方有一个JAR文件(我已经将Admob JAR文件复制到我的src文件夹中),然后将其添加为Java路径库。它不会出现在Package Explorer下,所以您不会注意到它,但是它会被计算两次,导致可怕的Dalvik错误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.

另一个可能的原因可能是包名冲突。假设你有一个包裹。xyz和一个名为a的类。这个包中的java和另一个库项目(该项目被添加到这个项目的依赖项中)包含相同的com. abc.xyza。java,你会得到完全相同的错误。这意味着,您对同一个文件A有多个引用。java并不能正确地构建它。

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.

在其他方面,如果您不小心或有意地在类路径文件中手动编辑/添加任何东西,可能会发生这种情况。在某些情况下,我们可能会添加android。用于生成java doc的类路径文件的jar路径。在删除javadoc生成的代码之后,将会运行良好。如果还有的话,请检查一下。

#2


270  

I solved the problem.

我解决了这个问题。

This is a JAR file conflict.

这是一个JAR文件冲突。

It seems that I have two JAR files on my buildpath that include the same package and classes.

似乎我的buildpath上有两个JAR文件,其中包含相同的包和类。

smack.jar and android_maps_lib-1.0.2

打。jar和android_maps_lib-1.0.2

Deleting this package from one of the JAR files solved the problem.

从一个JAR文件中删除这个包可以解决这个问题。

#3


125  

Windows 7 Solution:

Windows 7的解决方案:

Confirmed the problem is caused by ProGuard command line in the file
[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat

确认问题是由ProGuard命令行在文件[Android SDK安装目录]\tools\ ProGuard \bin\proguard.bat中引起的。

Edit the following line will solve the problem:

编辑下一行将解决问题:

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*

to

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

#4


94  

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.

您可以轻松地解决这个问题(使用Eclipse Android开发工具,构建:v22.0.1-685705),在导出(un)签名的Android应用程序时,关闭菜单>“项目”>“自动构建”。在那之后,别忘了把它打开。

#5


53  

If you have ADT revision 12+, you should update your proguard from 4.4 -> 4.6 (as described here). Also, you should leave ...\bin\proguard.bat file in the orginal form.

如果您有ADT修订12+,您应该从4.4 -> 4.6(这里描述的)更新您的proguard。此外,你应该离开…\bin\proguard。在组织形式的bat文件。

Just download it from the web, and copy lib folder from downloaded package to the :

只需从网上下载,并从下载的包复制lib文件夹到:

[Android SDK Installation Directory]\tools\proguard\lib

(Android SDK安装目录)\ \混淆器\ lib工具

#6


40  

EDIT (new solution):

编辑(新解决方案):

It looks like the previous solution is only a bypass. I managed to finally fix the problem permanently: In my case there was a mismatch in android-support-v4 files in my project and in the Facebook project that is referenced in my project.

看起来之前的解决方案只是一个旁路。我最终成功地解决了这个问题:在我的案例中,我的项目和项目中引用的Facebook项目中的android-support-v4文件不匹配。

I found this error by performing Lint Check (Android Tools / Run Lint: Check for Common Errors)

我通过执行Lint检查发现了这个错误(Android工具/运行Lint:检查常见错误)

My previous solution:

我以前的解决方案:

I've tried any possible solution on this site - nothing helped!!!

我在这个网站上尝试了任何可能的解决方案-没有任何帮助!!!

Finally I've found an answer here: https://groups.google.com/forum/#!topic/actionbarsherlock/drzI7pEvKd4

最后,我在这里找到了一个答案:https://groups.google.com/forum/#!

Easy steps:

简单的步骤:

Go to Project -> uncheck Build Automatically

去项目->取消自动构建。

Go to Project -> Clean... , clean both the library project and your app project

去项目->清洁…,清理图书馆项目和你的应用项目。

Export your app as a signed APK while Build Automatically is still disabled

在自动构建时,将应用程序导出为已签名的APK。

#7


30  

Here's another scenario, and solution:

下面是另一个场景和解决方案:

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

如果您在更新了Eclipse ADT之后最近遇到了这个问题:

  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. 在您的应用程序项目中,检查指向您的库项目的任何链接源文件夹(它们在表单“LibraryName_src”中有名称)。
  3. Select all those projects, right-click, choose "Build Path"->"Remove from Build Path".
  4. 选择所有这些项目,右键单击,选择“构建路径”->“从构建路径中移除”。
  5. Choose "Also unlink the folder from the project", and click "Yes".
  6. 选择“也断开项目的文件夹”,点击“是”。
  7. Clean, rebuild and redeploy the project.
  8. 清理、重建和重新部署项目。

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.

似乎原因是一些以前版本的ADT链接库项目源文件夹到“子”项目,而当前的ADT/Dex组合与那个解决方案不兼容。

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

编辑:这是通过一个Android开发博客的条目来确认的,具体来说就是这个——看第8段。

#8


29  

Go to Project and then uncheck "Build Automatically".Then try to export the project and the error is gone.

进入项目,然后取消“自动构建”。然后尝试导出项目,错误就消失了。

#9


26  

This can also be caused if you have added Android.jar file to your build path, perhaps by an accidental quick fix in Eclipse. Remove it with right clicking Project -> build path -> configure build path -> android.jar, remove.

如果你添加了Android,也会造成这种情况。jar文件到您的构建路径,可能是在Eclipse中偶然的快速修复。使用右击项目->构建路径->配置构建路径-> android。jar、删除。

#10


25  

Simply cleaning the project has worked for me every time this error has come up.

每次这个错误出现时,简单地清理这个项目就对我有效了。

#11


16  

My own and only solution that I found today after four hours of testing all the solutions, is a combination of many solutions provided here:

我自己的和唯一的解决方案,我今天在四个小时的测试所有的解决方案,是一个组合的许多解决方案在这里提供:

  • Delete project from Eclipse
  • 删除从Eclipse项目
  • Delete files in \bin and \gen from project folder
  • 从项目文件夹中删除\bin和\gen的文件。
  • Remove references to libraries into .classpath file in root project folder
  • 将对库的引用删除到根项目文件夹中的.classpath文件中。
  • Restart Eclipse with command line : eclipse -clean
  • 使用命令行重新启动Eclipse: Eclipse -clean。
  • Import project
  • 导入项目
  • Right click on project - select Properties > Java Build Path > Libraries and remove everything else than Android XX.Y
  • 右键点击项目-选择属性> Java构建路径>库,删除所有其他的东西,而不是Android XX.Y。
  • Finally clean project, wait for automatic Building or Build it
  • 最后清理项目,等待自动建立或建造。
  • Launch and now it works! At least for me...
  • 发射,现在成功了!至少对我来说……

I tried every step at a time and many combinations, but only the succession of all steps at once made it! I hope I won't face this again...

我尝试了每一步的每一步和许多组合,但只有所有步骤的演替立刻成功了!我希望我不会再面对这个……

#12


14  

Just for the other people who still have this problem and they have tried the above answers but still getting the error (which was my case), then my solution was to delete the project from Eclipse and re-import it again.

对于仍然存在这个问题的其他人,他们已经尝试了上面的答案,但是仍然得到了错误(这是我的情况),然后我的解决方案是从Eclipse中删除项目并再次导入它。

This made the Android library to be added again to my referenced libraries, so now I have two Android JAR files referenced, hence I deleted one of them and now it compiles fine.

这使得Android库再次被添加到我的引用库中,所以现在我有两个Android JAR文件被引用,因此我删除了其中一个,现在它可以编译了。

Solution: Delete the project from Eclipse IDE and then re-import it again, then check for the above solutions.

解决方案:从Eclipse IDE中删除项目,然后再重新导入它,然后检查上面的解决方案。

#13


10  

Ran into this problem myself today. Cleaning and rebuild did not fix the problem. Deleting and reimporting the project didn't help either.

今天我自己遇到了这个问题。清理和重建并没有解决问题。删除和重新导入项目也没有帮助。

I finally traced it back to a bad additions to my .class file. I think this was added by the plugin tools when I was trying to fix another problem, removing it got rid of the "Conversion to Dalvik format failed with error 1" build error:

最后,我将它追溯到我的.class文件的一个不好的添加。我想,当我试图修复另一个问题时,插件工具添加了这个功能,删除了它,去掉了“对Dalvik格式的转换失败的错误1”构建错误:

<classpathentry kind="lib" path="C:/dev/repository/android-sdk-windows/platforms/android-3/android.jar">
    <attributes>
        <attribute name="javadoc_location" value="file:/C:/dev/repository/android-sdk-windows/docs/reference"/>
    </attributes>
    <accessrules>
        <accessrule kind="nonaccessible" pattern="com/android/internal/**"/>
    </accessrules>

#14


9  

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

对我来说,在我的构建路径中出现了一个额外的JAR引用。我删除了这个,它现在起作用了。

#15


8  

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

我的问题是由ADT版本12.0和ProGuard集成引起的。这个bug有很好的文档记录,解决方案也在文档中。

Solution is in here

解决方案是在这里

ProGuard command line

混淆器命令行

#16


8  

I've dealt with this problem when using Sherlock ActionBar library in my project. You could do the following step, it's work for me.

在我的项目中使用Sherlock ActionBar库时,我已经解决了这个问题。你可以做下面的步骤,这对我很有效。

  1. Right click to your project, select properties.
  2. 右键单击您的项目,选择properties。
  3. A dialog will show up, select 'Java build path' on the left menu.
  4. 将出现一个对话框,在左侧菜单中选择“Java构建路径”。
  5. Remove 'Android dependencies' and 'Android private libraries' on the right panel then click OK
  6. 在右面板上删除“Android依赖项”和“Android专用库”,然后单击“确定”。
  7. Clean your project (select menu Project --> Clean)
  8. 清理你的项目(选择菜单项目——> Clean)
  9. Right click your project, select Android Tools -> Fix project properties
  10. 右键单击项目,选择Android Tools ->修复项目属性。
  11. Clean project once again.
  12. 再次清洁项目。
  13. Restart your computer
  14. 重新启动你的电脑
  15. Open eclipse and Export apk
  16. 打开eclipse并导出apk。

Hope that will help you.

希望能帮到你。

#17


7  

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

在我的例子中,问题在于OpenFeint API项目。我增加了OpenFeint作为图书馆项目:

“转换到Dalvik格式错误1”外部JAR。.

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

它也被添加到构建路径中,ADT工具16给出了这个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 :)

右键单击您的项目并单击build path,配置构建路径,然后查看该映像并从这里删除您的项目OpenFeint,然后全部完成:)

“转换到Dalvik格式错误1”外部JAR。

#18


7  

I found something else. Android uses the /libs directory for JAR files. I have seen the "Conversion to Dalvik format failed with error 1" error numerous times, always when I made a mistake in my JAR files.

我发现别的东西。Android为JAR文件使用/libs目录。我曾多次看到“转换为Dalvik格式错误1”错误,总是在我的JAR文件中出错。

Now I upgraded Roboguice to a newer version, by putting the new JAR file in the /libs directory and switching the class path to the new version. That caused the Dalvik error.

现在,我将Roboguice升级到一个新的版本,将新的JAR文件放入/libs目录中,并将类路径切换到新版本。这导致了Dalvik错误。

When I removed one of the Roboguice JAR files from the /libs folder, the error disappeared. Apparently, Android picks up all JAR files from /libs, regardless of which ones you specify in the Java build path. I don't remember exactly, but I think Android started using /libs by default starting with Android 4.0 (Ice Cream Sandwich, ICS).

当我从/libs文件夹中删除了一个Roboguice JAR文件时,错误就消失了。显然,Android会从/libs中获取所有JAR文件,不管您在Java构建路径中指定了哪些文件。我不太记得了,但我认为Android从默认开始使用/libs开始使用安卓4.0(冰淇淋三明治,ICS)。

#19


7  

Updating Proguard to latest version solved it for me.

更新Proguard到最新版本为我解决了它。

  • My proguard path was C:\Program Files (x86)\Android\android-sdk\tools\proguard\
  • 我的混淆器路径C:\Program Files (x86)\Android\ android sdk \混淆器\ \工具
  • I downloaded the new version from here
  • 我从这里下载了新版本。
  • and replaced both bin and lib folders
  • 并替换了bin和lib文件夹。

THANK GOD!

感谢上帝!

#20


7  

In general, it seems that this problem comes when there are unnecessary JAR files in build path.

一般来说,当构建路径中有不必要的JAR文件时,这个问题就会出现。

I faced this problem while working on IntelliJ IDEA. For me it happened because I added JUnit and Mockito libraries which were being compiled at runtime. This needed to be set to "testing" in module properties.

我在处理IntelliJ IDEA的时候遇到了这个问题。对我来说,这是因为我在运行时添加了JUnit和Mockito库。这需要在模块属性中进行“测试”。

#21


6  

None of previously proposed solutions worked for me. In my case, the problem happened when I switched from referencing a library source code folder to using the library JAR file. Initially there was an Android library project listed under the Android application project Properties\ Android page\ Library section, and the library compared also in project explorer tree as a link to the library source directory.

之前没有一个解决方案对我有效。在我的例子中,当我从引用一个库源代码文件夹切换到使用library JAR文件时,问题就发生了。最初在Android应用程序项目属性\ Android page\ library部分中列出了一个Android库项目,并且在project explorer树中作为一个链接到库源目录。

In the first place, I just deleted the directory link from the project tree and I added the JAR library to the build path, but this caused the exception.

首先,我只是从项目树中删除了目录链接,然后将JAR库添加到构建路径中,但这导致了异常。

The correct procedure was (after changing back the build path and putting back the reference to the library source):

正确的步骤是(在更改了构建路径后,将引用返回到库源):

  • properly remove the library source directory link by actually removing the reference from application project Properties\ Android page

    通过实际删除应用程序项目属性(Android)页面中的引用,适当地删除库源目录链接。

  • adding the library JAR to the application project build path as usual.

    像往常一样将库JAR添加到应用程序项目构建路径中。

#22


6  

None of the listed solutions worked for me.

所有列出的解决方案都不适合我。

Here's where I was having a problem:

我的问题是:

I added the jSoup external JAR file to my project's path by first putting it in a source folder called "libs", and then right clicking on it, Build Path -> add to build path. This threw the Dalvik conversion error. It said I had "already included" a class from that JAR file. I looked around the project's directory and found that the place where it was "already included" was in fact the bin directory. I deleted the JAR file from the bin directory and refreshed the project in Eclipse and the error went away!

我将jSoup外部JAR文件添加到项目的路径中,首先将它放入一个名为“libs”的源文件夹中,然后右键单击它,构建路径->添加到构建路径。这就抛出了Dalvik转换错误。它说我已经“包含”了一个来自JAR文件的类。我查看了这个项目的目录,发现它“已经包含”的地方实际上是bin目录。我从bin目录中删除了JAR文件,并在Eclipse中刷新项目,错误就消失了!

#23


5  

All the solutions above didn't work for me. I'm not using any precompiled .jar. I'm using the LVL and the Dalvik errors where all related to the market licensing library.

以上所有的解决方案对我都不起作用。我没有使用任何预编译的.jar。我使用的是LVL和Dalvik错误,这些错误都与市场许可库相关。

The problem got solved by deleting the main project and reimporting (create a new project from existing sources).

通过删除主项目和重新导入(从现有源创建一个新项目)来解决这个问题。

#24


5  

I had the same problem and none of these solutions worked. Finally, I saw in the console that the error was due to duplicated class (one in the existing project, one in the added jar file) :

我遇到了同样的问题,这些解决方案都没有奏效。最后,我在控制台看到了错误是由于重复的类(一个在现有的项目中,一个在添加的jar文件中):

java.lang.IllegalArgumentException: already added: package/MyClassclass;
[2011-01-19 14:54:05 - ...]: Dx1 error; aborting
[2011-01-19 14:54:05 - ...] Conversion to Dalvik format failed with error 1

So check if you are adding jar with duplicated classes in your project. If yes, try removing one of them.

因此,检查您是否在项目中添加了重复类的jar。如果是,请尝试删除其中一个。

It worked for me.

它为我工作。

#25


5  

Often for me, cleaning the project DOES NOT fix this problem.

通常对我来说,清理项目并不能解决这个问题。

But closing the project in Eclipse and then re-opening it does seem to fix it in those cases...

但是在Eclipse中关闭项目,然后重新打开,似乎在这些情况下修复了它……

#26


5  

I ran into this problem but my solution was twofold. 1.) I had to add an Android target version under project -> properties -> Android. 2.) I didn't have all google 'third party add-ons'. Click in AVD SDK manager under available packages -> third-party add-ons -> Google Inc. I downloaded all of the SDKs and that solved my issue.

我遇到了这个问题,但我的解决方法是双重的。1)。我必须在project ->属性-> Android上添加一个Android目标版本。我没有谷歌的第三方插件。在现有的软件包->第三方插件->谷歌Inc.下点击AVD SDK管理器,我下载了所有的SDK,解决了我的问题。

#27


5  

I am using Android 1.6 and had one external JAR file. What worked for me was to remove all libraries, right-click project and select Android Tools -> *Fix Project Properties (which added back Android 1.6) and then add back the external JAR file.

我使用的是Android 1.6,并且有一个外部JAR文件。为我工作的是删除所有的库,右键单击项目并选择Android工具-> *修复项目属性(添加了Android 1.6),然后添加外部JAR文件。

#28


5  

I ran into this problem because the Android-Maven-plugin in Eclipse was apparently not recognizing transitive references and references referenced twice from a couple of projects (including an Android library project), and including them more than once. I had to use hocus-pocus to get everything included only once, even though Maven is supposed to take care of all this.

我遇到了这个问题,因为Eclipse中的Android- maven -plugin显然不承认两个项目(包括一个Android库项目)所引用的可传递引用和引用,而且包含不止一次。我必须使用hocus-pocus才能得到所有的东西,即使Maven应该负责所有这些。

For example, I had a core library globalmentor-core, that was also used by globalmentor-google and globalmentor-android (the latter of which is an Android library). In the globalmentor-android pom.xml I had to mark the dependency as "provided" as well as excluded from other libraries in which it was transitively included:

例如,我有一个核心的图书馆globalmentor-core,它也被globalmentor-google和globalmentor-android(后者是一个Android图书馆)使用。globalmentor-android pom。我必须将依赖项标记为“提供”,并将其从其他库中排除,包括:

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-core</artifactId>
        <version>1.0-SNAPSHOT</version>
        <!-- android-maven-plugin can't seem to automatically keep this from being
             included twice; it must therefore be included manually (either explicitly
             or transitively) in dependent projects -->
        <scope>provided</scope>
    </dependency>

Then in the final application pom.xml I had to use the right trickery to allow only one inclusion path---as well as not explicitly including the core library:

然后在最后的应用程序pom中。我必须使用正确的欺骗手段只允许一个包含路径——以及不显式地包括核心库:

    <!-- android-maven-plugin can't seem to automatically keep this from being
        included twice -->
    <!-- <dependency> -->
    <!-- <groupId>com.globalmentor</groupId> -->
    <!-- <artifactId>globalmentor-core</artifactId> -->
    <!-- <version>1.0-SNAPSHOT</version> -->
    <!-- </dependency> -->

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-google</artifactId>
        <version>1.0-SNAPSHOT</version>
        <exclusions>
            <!-- android-maven-plugin can't seem to automatically keep this from
                being included twice -->
            <exclusion>
                <groupId>com.globalmentor</groupId>
                <artifactId>globalmentor-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.globalmentor</groupId>
        <artifactId>globalmentor-android</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

#29


5  

In my case

在我的例子中

project->properties->java build path -> in order and export tab -> uncheck android-support-v4.jar

项目->属性->java构建路径->在order和export标签-> uncheck android-support-v4.jar。

#30


5  

Just clean the project

清洁项目

If this does not work try the other solutions

如果这不是工作,尝试其他的解决方案。