0

I have a library module with a dummy manifest (which is an exact copy of my application manifest but with package name changed) which i used in the past (eclipse) to test the library without an application module. Now in android studio i can test and debug with breakpoints the library launching it with my application module, so the dummy manifest of the library is not neccesary anymore.

Can i delete the library manifest before release compile? Manifest merger is giving me a lot of problems, duplicating a lot of things on my manifest, so if it is possible whould be better for me to delete the library module.

It is safe to delete it or this will give me problems in the future?

Thanks

NullPointerException
  • 36,107
  • 79
  • 222
  • 382
  • AFAIK, you need a manifest, but other than the root `` element and `package` attribute, nothing else inside the manifest is needed. – CommonsWare Aug 23 '15 at 20:37
  • ummm, can i delete all the content (leaving only element with package) and get rid of my manifest merger problems safely? – NullPointerException Aug 23 '15 at 20:40
  • I have no way to know, as I do not know what is in the library's manifest, what is in the app's manifest, and what is in the code bases for the library and the app. You need to make sure that your merged manifest has everything you need, but only you can do that, not I. – CommonsWare Aug 23 '15 at 20:42
  • in which circuntances whould need content in the manifest a library module of an Android Project? – NullPointerException Aug 23 '15 at 20:48
  • Well, logically, the library module's manifest should reflect what is in the library. If the library needs X permission, that `` element should be in the library. If the library publishes `FooActivity`, and that activity should be used by default for all apps using the library, the library's manifest should have the `` element. And so on. An app's manifest should have the things that are in the app (e.g., stuff not coming from the library) or overrides for what the library thinks is the right answer but the app does not. – CommonsWare Aug 23 '15 at 20:50
  • did you mean that activities, receivers etc... that are used in the library, should be declared only in the library and not in the application module? I don't understand why. When i download a android library from a third party, i always must declare activities, receivers etc.. from the library on my application. – NullPointerException Aug 23 '15 at 20:56
  • "When i download a android library from a third party, i always must declare activities, receivers etc.. from the library on my application" -- not for the past year and change in Android Studio, at least for well-written libraries. – CommonsWare Aug 23 '15 at 20:57
  • OK, so you mean that starting from recently, third party libraries will not need anymore to tell you which activities, permissions etc.. you need to declare in your manifest if you are using these libraries? Then, why in official android admob documentation they are still telling that you must add content to your manifest? https://developers.google.com/admob/android/quick-start – NullPointerException Aug 23 '15 at 21:07
  • "third party libraries will not need anymore to tell you which activities, permissions etc.. you need to declare in your manifest if you are using these libraries?" -- yes. That is most of the reason why the manifest merger process exists. "Then, why in official android admob documentation they are still telling that you must add content to your manifest?" -- you would have to ask AdMob. I am not AdMob, nor am I responsible for their documentation. – CommonsWare Aug 23 '15 at 21:10
  • OK thanks CommonsWare. So the best option for me is to delete all the content from my application module Manifest and let manifestMerger to add it getting it from my library module Manifest? (my application module is empty, does not have source code, it is an empty dummy application module that launches the main activity of my library module) – NullPointerException Aug 23 '15 at 21:12
  • I would recommend just getting rid of the library module and folding everything into the app module. Unless you are planning on 2+ apps using the library, I do not know why you would bother with the headache of having a library. – CommonsWare Aug 23 '15 at 21:17
  • it is a must for this project, it will be used by third parties in the future. Whould you recommend to do what i told in the previous comment? – NullPointerException Aug 23 '15 at 21:18
  • "it will be used by third parties in the future" -- then you should be setting up the library with those third parties in mind. Put the stuff in the library's manifest that those third parties should be using. I cannot tell you if that is everything from your app module or not. – CommonsWare Aug 23 '15 at 21:23
  • ok I tryed it, it works for activities but not for receivers, providers and special permisions like C2DM which needs application package name as an atribute inside the elements. Why? because these elements are merged in the final manifest with the same package name as the library, not with the package name of the application, and all three elements needs to have the application package name. The only way to solve this is to duplicate the elements in both library and application modules with tools:replace or tools:remove atributes to keept only the application package elements? – NullPointerException Aug 24 '15 at 14:18
  • "because these elements are merged in the final manifest with the same package name as the library, not with the package name of the application, and all three elements needs to have the application package name" -- use [manifest placeholders](http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Placeholder-support) for those. – CommonsWare Aug 24 '15 at 14:22
  • absolutly perfect, thanks a lot – NullPointerException Aug 24 '15 at 14:46
  • please post an answer, and i will give you the correct signal – NullPointerException Aug 24 '15 at 14:51

1 Answers1

0

Well, i will post an answer made with the comments of CommonsWare (thank you!)

Bassically, activities, receivers etc... that are used in the library, should be declared only in the library and not in the application module, manifest merger will add them into the final manifest.

It works for activities but not for receivers, providers and special permisions like C2DM which needs application package name as an atribute inside the elements. Why? because these elements are merged in the final manifest with the same package name as the library, not with the package name of the application, and all three elements needs to have the application package name. For those, we should use use manifest placeholders: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Placeholder-support

Thanks CommonsWare

NullPointerException
  • 36,107
  • 79
  • 222
  • 382