android 库项目和活动
我正在开发一个 Android SDK 库。在这个库中,我声明并使用了一些活动。现在我尝试将库包含在应用程序中,但我注意到我必须在应用程序中声明所有库活动。这是一件非常糟糕的事情,因为在库中,我包含了很多活动,而开发人员必须将所有活动复制到他自己的应用程序中。有解决办法吗?
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 that I must declare all the library activities in the app. This is a very bad thing because in the library, I've included a lot of activities and the developer has to copy all the activities in his own app. Is there a solutions to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,这是目前库的已知限制。 Android 开发社区中有很多关于在未来修复这个问题的讨论,但目前这是他们如何处理库的限制。
来自 doc
另外,Mark Murphy 此处给出了很好的答案。
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
Also, excellent answer here by Mark Murphy.
更新 1: 使用 Gradle 时,清单合并现在会自动完成。有关其工作原理以及如何解决冲突的更多详细信息,请访问此处 (感谢 Guy.gc 的评论)
原始帖子:
更新此线程:现在可以进行自动合并。您只需添加
到您的project.properties 中。 在 Android 中使用新的“manifestmerger”属性也讨论了这一点。
我知道这是一个旧线程,但我只是偶然发现它并希望防止其他人(包括我)认为这是不可能的。在我的项目中,这一行完全足以在图书馆消耗应用程序中使用活动。
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
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.