Questions tagged [android-library]

An Android library project is a development project that holds shared Android source code and resources. Other Android application projects can reference the library project and, at build time, include its compiled sources in their .apk files.

An Android library project is a development project that holds everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that can be used as a dependency for an Android app module.

Android Team started revamping the whole design of Android library project since SDK r14 and is going to move from source-based mechanism to compiled-code based library mechanism, in order to support distributing Android library project as a single self-contained jar file. More details in their official blog.

A library module is useful in the following situations:

  • When you're building multiple apps that use some of the same components, such as activities, services, or UI layouts.
  • When you're building an app that exists in multiple APK variations, such as a free and paid version and you need the same core components in both.

Useful links

1883 questions
25
votes
0 answers

missingDimensionStrategy everywhere - Is there no better way?

I have a library project - let's call it lib1 which has custom flavorDimensions specified. More precisely there is buld dimension with actual flavors full and production. This library is used by another library project (lib2) with no custom…
bio007
  • 893
  • 11
  • 20
25
votes
2 answers

What is the purpose of the Android Private Libraries, Referenced Libraries and Android Dependies in android project hierarchy?

I want to know the exact use of Android Private Libraries, Referenced Libraries and Android Dependencies in an android project hierarchy?
Bruce
  • 8,609
  • 8
  • 54
  • 83
24
votes
2 answers

android library project and Activities

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…
ets23
  • 241
  • 1
  • 2
  • 3
24
votes
2 answers

Should Android libraries define targetSdkVersion?

I understand why it is useful for a library to define the minSdkVersion, but does a library having the defined targetSdkVersion add any value? I'm not sure if there would be any issues with libraries having lower and higher targetSdkVersions than…
Anonsage
  • 8,030
  • 5
  • 48
  • 51
24
votes
1 answer

Aspectj with android library

I have a lib that use aspects and is available via maven, now I'm trying to use that lib in an android application. If I include this plug-in in the app gradle file, everything works fine, but my goal is to extract the classpath…
letz
  • 1,762
  • 1
  • 20
  • 40
23
votes
4 answers

For android library projects, is meaningful in manifest?

It's all pretty much in the title. Although I see specified in all the example library project's AndroidManifest.xml I've seen, I have a feeling it's irrelevant. In fact, I suspect that is also irrelevant, as are all of…
Andy Dennie
  • 6,012
  • 2
  • 32
  • 51
23
votes
2 answers

Export Android Library as AAR file

I have created a library module in my project. Now, I want to share/publish this library with others. Sharing a .aar file would be fine for now. I went through the article - https://developer.android.com/studio/projects/android-library and found the…
Suneesh Ambatt
  • 1,347
  • 1
  • 11
  • 41
23
votes
5 answers

How to prevent client from seeing internal private classes in Android library ?

I have a library with several packages- lets say package a; package b; inside package a I have public a_class inside package b I have public b_class a_class uses b_class. I need to generate a library from this , but I do not want the Client to see…
Croc
  • 485
  • 5
  • 14
22
votes
2 answers

Can I mark a resource in my android project as deprecated?

I have an android library for which I would like to mark some resources as deprecated. Drawables, dimensions, durations... I read somewhere that I could add deprecated="deprecated" to the resource definition but it doesn't seem to do anything. In…
Grégory Jourdan
  • 367
  • 3
  • 12
22
votes
5 answers

Share library project's manifest services and permissions

I want to develop a library project which consists of a GCMIntentService and it performs GCM registration process and receives messages sent over GCM. I have used AIDL to expose my library project service to host application,but I need to declare…
21
votes
1 answer

Bundling react-native project as iOS framework or (.aar) Android library

I am exploring the possibility of using react-native to create a iOS framework (android library), which can be distributed and can be integrated with apps by including while building a app. For example, maintaining single codebase to create a…
vagdwd
  • 243
  • 2
  • 7
20
votes
6 answers

java.lang.IllegalStateException: Could not initialize plugin: MockMaker

Trying to run instrumentation test on AS. stuck with this Error: java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker at…
AskQ
  • 4,215
  • 7
  • 34
  • 61
20
votes
2 answers

Debug native code in Android Library

My workspace layout is: . ├── ApplicationLibrary │   ├── AndroidManifest.xml │   ├── ... │   ├── jni │   ├── libs │   ├── ... │   └── src └── Application    ├── AndroidManifest.xml    ├── ant.properties    └── ... How can I debug the native…
spacifici
  • 2,186
  • 2
  • 16
  • 28
19
votes
2 answers

How to make Android library resources private?

How do I make the resources (string, dimen, color, etc.) in my Android library module private? I've tried both documented ways of doing this and neither work... Following the official Android doc of creating a res/values/public.xml does not work;…
19
votes
2 answers

Create STANDALONE Android Studio (1.5) library project

I need to create an Android Library and deliver the final .jar file to the clients. I am new to Android development (three days). I've been developing iOS for the last 4 years. I went through Google's official documentation and tutorials to get a…
vale4674
  • 4,161
  • 13
  • 47
  • 72