Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android library project and Activities

Tags:

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?

like image 467
ets23 Avatar asked Feb 18 '11 21:02

ets23


People also ask

What is Android library project?

An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest.

How do I create a library project in Android Studio?

Creating The Android Library Open Android Studio and create a new Project. Name your application as ToasterExample and your project name as Toaster. The ToasterExample will be our sample application to show an example use of our application. Click on Finish and your project will be ready.

What is AAR Android?

The . aar bundle is the binary distribution of an Android Library Project. An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code. A AAR file can be included in the build process of an Android application similar to a JAR file.


1 Answers

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.

like image 121
Nick Campion Avatar answered Nov 25 '22 05:11

Nick Campion