44

In the newest version of ADT (version 20 preview 3), they say that it's possible to make the libraries' manifest file become mergeable with projects that use them:

Automatic merging of library project manifest files into the including project's manifest. Enable with the manifestmerger.enabled property.

How and where do I use it? I can't see content assist helping with me on this anywhere.

halfer
  • 19,824
  • 17
  • 99
  • 186
android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • 1
    Also, is there any information about what it merges? I assume activities? – Peterdk Jun 28 '12 at 14:51
  • i think so . i also think all of the rest , like permissions. – android developer Jun 28 '12 at 23:17
  • I noticed that it doesn't merge launcher properties of an activity, but all the activities it definitely does. – Peterdk Jul 01 '12 at 13:19
  • odd . maybe you should tell google about it. thank you for telling me ,so that if there are problems, i will know where to look for them. – android developer Jul 01 '12 at 15:40
  • You can see the merged manifest in the bin directory. It does merge the launcher properties after all, but somehow it doesn't get compiled in because the app won't launch. – Peterdk Jul 04 '12 at 12:11
  • @Peterdk - yes this is a pain - a bug has been reported for it here: https://code.google.com/p/android/issues/detail?id=41776 – Mr. Bungle Sep 25 '14 at 03:49
  • @Mr.Bungle Thank you for pointing it out. I've tried to use this multiple times, sometimes thinking it works, but then it caused a lot of issues... – android developer Sep 25 '14 at 08:53

4 Answers4

65

Add the following line to your project.properties file of your application project.

manifestmerger.enabled=true 

Introduced with Android SDK Tools, Revision 20 (June 2012):
https://developer.android.com/studio/releases/sdk-tools

Build System
    * Added automatic merging of library project manifest files into the including project's manifest.       Enable this feature with the manifestmerger.enabled property.

Dan Dar3
  • 1,199
  • 13
  • 23
Kevin McMahon
  • 2,643
  • 25
  • 31
  • thanks . seems like they've added it lately in their documentation and videos. i've forgot i even asked this question. – android developer Jun 27 '12 at 23:21
  • I dude, it doesn't work for me, sadly... I've added this line in my project.properties but since I call `startActivity` in my code, it crashes with `ActivityNotFoundException`... What can I do to prevent that ? Thx in advance mate. – ChristopheCVB Jul 02 '12 at 13:05
  • 1
    My bad, I was just adding the `activity` tag in the Libs manifest with no `application` tag... Works great ! thanks a lot ! – ChristopheCVB Jul 02 '12 at 13:29
  • 7
    google has a video containing this feature : http://www.youtube.com/watch?feature=player_embedded&v=Erd2k6EKxCQ#t=2939s – android developer Jul 04 '12 at 21:42
  • ummmm... i've tested this new feature , and it doesn't import the activities . what's going on ? is there any sample that i can download in order to see if i'm doing something wrong? – android developer Jul 12 '12 at 07:45
  • Are you running into the Eclipse bug that @Vadimo linked to below? I've shipped a few apps already that use manifest merging and it works as expected for me. – Kevin McMahon Jul 12 '12 at 18:42
  • 1
    well i didn't sign the app and i still got this behavior . it just doesn't merge anything. – android developer Jul 15 '12 at 13:53
  • Does not work for me as well (debug version). I have ADT20, Eclipse Indigo R2 on a Mac. Probably have to wait until all the details are ironed out. Looking forward for it, though. – Guy Jul 16 '12 at 07:46
  • How do you use it on Android Studio? – android developer Jan 05 '15 at 23:32
  • @KevinMcMahon After using this line in project.properties, my project R file missing! And i got too many errors on R.something.someID. – Dr.jacky May 13 '15 at 08:41
  • Vdieos are not documentation. – Glenn Maynard Mar 15 '16 at 04:01
9

If you want to merge android library project manifest and your current project manifest, you have to add manifestmerger.enabled=true in your project.properties file where you referred your library project. But, you should be confirmed some point like ADT version, Also Minimum and target SDK should be same as library project.

Ratna Halder
  • 1,954
  • 16
  • 17
  • 1
    I was facing the problem that R.java was not found anymore, changing the min and target sdk solved it for me. thanks. – Anthea Jun 13 '14 at 07:30
5

FYI: manifestmerger.enabled=true won't merge the manifest files if you are using eclipse export signed App. As noted here it seems to be a bug. http://code.google.com/p/android/issues/detail?id=34623

It was a bit of a hassle for me to set up merging correctly as well. (restarting eclipse, open close project..) To find out if merging is working take a look at the file in ../Your_Main_Project/bin/AndroidManifest.xml. If merging worked you will see the complete result in this file.

EDIT: This bug was fixed in ADT v20.0.1 (Juli 2012): http://developer.android.com/tools/sdk/eclipse-adt.html

Vad1mo
  • 5,156
  • 6
  • 36
  • 65
  • really ? so why did they make this feature? i thought that eclipse is the best thing that google support as an IDE . also , even without signing the app (meaning just compile&run from eclipse) , it didn't work for me. – android developer Jul 12 '12 at 19:22
  • its not a feature its a bug. It was all running fine for me when I tried to export the signed App. – Vad1mo Jul 13 '12 at 14:22
  • you didn't understand me . it's a feature that simply doesn't work for me , not even when running the app unsigned . i don't get it . how could they publish a feature that doesn't work at all ? – android developer Jul 13 '12 at 18:03
  • This bug was fixed in ADT 20.0.1 (July 2012): http://developer.android.com/tools/sdk/eclipse-adt.html – JesperB Jul 31 '12 at 11:04
2

I was facing some errors during manifest merging (R.java file went missing) so alternately I explicitly copied the manifest contents (e.g. I copied just the activity contents) from the library project manifest and put them in my main project manifest. That resolved the error and everything seems to be working well so far. Let me know if anyone feels this is not a recommended alternative to manifest merging.

Sid M
  • 130
  • 3
  • 15
  • I can confirm that after 3 years into the "bug was fixed" date we are still having problems with the merger. Disabling it and manually merging files resolved the issue on Eclipse. No problems with Android Studio's auto merge so far. – Kerem May 12 '15 at 12:48