android library project and Activities

后端 未结 2 1821
南笙
南笙 2020-12-13 20:00

I\'m developing an Android SDK library. In this library I\'ve declared and used some Activities. Now I\'ve tried to include the library in an application but I\'ve noticed t

相关标签:
2条回答
  • 2020-12-13 20:13

    Update 1: When using Gradle, Manifest merging is done now automatically. More details on how it works and how to resolve conflicts can be found here (thanks for the remark guy.gc)

    Original post:

    To update this thread: auto merge is now possible. You would only have to add

    manifestmerger.enabled=true
    

    to your project.properties. Using the new "manifestmerger" property in Android discusses this also.

    I know this is an old thread but I just stumbled upon it and want to prevent others (me included) from thinking it is not possible. This one line was totally enough in my projects to make use of Activities in the library-consuming App.

    0 讨论(0)
  • 2020-12-13 20:32

    No, this is a known limitation of the libraries at the moment. There is a lot of discussion in the android development community of fixing this in the future, but for now it is a limitation of how they do libraries.

    From the doc

    In the manifest file of the application project, you must add declarations of all components that the application will use that are imported from a library project. For example, you must declare any <activity>, <service>, <receiver>, <provider>, and so on, as well as <permission>, <uses-library>, and similar elements.

    Also, excellent answer here by Mark Murphy.

    0 讨论(0)
提交回复
热议问题