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

8

35

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 final archive: duplicate entry: AndroidManifest.xml

Custodial answered 29/5, 2010 at 7:19 Comment(0)
R
54

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.

Rotative answered 27/11, 2010 at 18:56 Comment(4)
good to know, esp when having to include the project as a jar for test project - dtmilano.blogspot.com/2009/12/…Brisco
How did you exclude AndroidManifest.xml when rebuilding the jar file?Illicit
My solution was to delete the manifest from the original app. This caused an error but I did not care, exported it as jar, added the jar to the project, and that's allJosiah
Or you can click export from eclipse then select the jar then you get a window unselect the AndroidManifest.xml in the upper right window and now click finish thats about itRubricate
C
3

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

Claud answered 9/2, 2012 at 10:15 Comment(0)
C
3

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.

Calipee answered 12/2, 2015 at 15:58 Comment(1)
this is what worked for me. and its a very simple solution.Disentwine
M
1

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.)

Mitrewort answered 6/5, 2012 at 13:9 Comment(0)
M
0

Cleaning the Project1 might help.

Mccormick answered 21/6, 2010 at 15:44 Comment(0)
T
0

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.

Tonsillectomy answered 18/9, 2013 at 9:11 Comment(0)
A
0

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.

Atrabilious answered 22/9, 2014 at 23:14 Comment(0)
S
0

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

Scrip answered 6/4, 2015 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.