开发者

How to fix "Error generating final archive: duplicate entry: AndroidManifest.xml"

I put two projects into Eclipse, called Project1 and Project2.

Project1 is independent, but Project2 must be dependent to Project1.

When I build the Project2, the error msg comes like this: Error generating f开发者_运维问答inal archive: duplicate entry: AndroidManifest.xml


I figured out what the problem was. I included a JAR file that had an AndroidManifest.xml file in it, which was conflicting with my own project's AndroidManifest.xml file. The solution in my instance was to rebuild the JAR file, making sure it excluded its own version of AndroidManifest.xml, then to re-include the new version of the JAR file into my project. You might need to clean the project after doing this.


I think you use Project1 as Library. So, when you export jar file you should unselect AndroidManifest.xml on "Select the resource to export".


I had got the same problem some days ago, if you put a JAR inside libs folder and the JAR has inside a AndroidManifest.xml you got the error. If you put the JAR outside the project (for example on desktop) and in "java Build Path" you use "Add external JAR" the problem is solved.


I got a second (ungracefull) AndroidManifest.xml file by including an Android.R package instead of the com.example.mypackage.R.

Symptoms: build seemed to work, but launching showed the existing Error in workspace, which needed to be fixed first. One AndroidManifest.xml was found in classes, the other in a file called resources.ap_ . I simply quickfixed (include android.R) workspace to hell.

edit: didn't work either, workspace still in in hell; problems in projects, which liked to be fixed...

edit1: can't find the package, with should hold the AndroidManifest.xml.

edit2: I consider to assume the second Manifest File in Android.jar - seems like each Manifest file results in generated 1 R.class. I erased complete workspace. Because it was playground anyway. (Then I set up Git.)


Cleaning the Project1 might help.


It is possible that you have similar compile time dependencies in your library project and your application project and the dex-er is not recognizing the duplicates.

If this is the case change the scope of the dependencies in your application project to the provided scope.

The dependencies will be included because they are in the library project, and they will not be duplicated because they are "provided" when compiling the application project.


You will get a series of error message related to AndroidManifest, main.xml, activity_main. So the best solution would be, rename them (using shift+ctrl+R) from one of the project to something else.

This solved my problem.


I could only fix it in Android Studio by deleting the out/ directory and letting it re-build everything again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜