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
42
votes
3 answers

how to start an activity in another module explicitly

I created an aar and i added it to my project as an module. in this module i have a HelloWorldActivity that i want to run. my module manifest looks like this.
Alireza Ahmadi
  • 5,122
  • 7
  • 40
  • 67
41
votes
2 answers

Android Library Module vs Feature Module

The latest update of Android Studio 3.0 allows creation of several module types. One of the new types is 'Feature Module' but I can't find details about it What is the difference between the existing Android Library Module and the Feature Module and…
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
41
votes
3 answers

Android Library Manifest vs. App Manifest

I've read similar questions here, but am still not clear on a couple of things. Using a Library Project means that my overall project will have two manifests -- one for the library and the other for the "main" app project -- and I'm not clear what…
35
votes
2 answers

Replace (or "Override") String in Android Library Project

I've been trying to make an android library project, and while the build process works fine, I've been running into some trouble with replacing a resource in the project which uses the library. In my library I have: A library_layout.xml…
jwriteclub
  • 1,604
  • 1
  • 17
  • 33
35
votes
5 answers

how to import your own github forked library into android studio

I found a nice open library on GitHub, I imported it into my Android Studio project using Gradle dependencies, but then I realized I need to make little modifications on it. So I forked the library on my GitHub, done the modifications and asked for…
avafab
  • 1,601
  • 3
  • 20
  • 38
35
votes
3 answers

Is proguard.cfg needed for library projects?

Assuming I need to apply the same rules for both an application project and a library project on which it relies, do I need to duplicate the content of proguard.cfg from the application to the library project? In other words, does the application's…
Regex Rookie
  • 10,432
  • 15
  • 54
  • 88
34
votes
5 answers

'Unresolved reference' errors for android library module referenced in app module

I have problems referencing my android library modules in my projects. Beside the main app module I use to have an android library module with either util stuff or as data module. I reference it in app module like that: dependencies { …
34
votes
4 answers

When using an Android Library Project how do you reference xml resources properly?

I have an Android Library Project that contains several styles/themes defined in its styles.xml file. Normally, when referencing this style in some other xml layout or manifest file, you would just write android:theme="@style/TheNameOfTheStyle" When…
cottonBallPaws
  • 21,220
  • 37
  • 123
  • 171
34
votes
6 answers

Android Library Project using Android Studio

This question might have been answered somewhere but couldn't find the appropriate one. I want to know how can I create a common utility library project in Android Studio. I want to write some common classes and some common methods within them to…
Harshad Kale
  • 17,446
  • 7
  • 30
  • 44
33
votes
4 answers

Proguard ignores config file of library

I'm facing a really weird problem for days now... I have a Gradle app with two modules, one main module and one library module. In both modules I have declared a proguard-rules.pro file path which is correct In both .gradle files I have…
Marian Klühspies
  • 15,824
  • 16
  • 93
  • 136
31
votes
8 answers

Unable to resolve superclass error when referencing .jar library

I did an Android project and run it. It ran successfully. I developed a web service in Java and hosted it. It ran successfully. I exported the webservice into a .jar and added it to my Android project. When I try to call a method in the web…
sakthi
  • 339
  • 1
  • 3
  • 7
29
votes
7 answers

Unable to Debug Library Projects with ADT v14 - Source Not Found

Ever since upgrading my current projects to use the new R14 Tools in Eclipse, I'm now unable to debug any code that exists in my library projects. When I hit a break point in my library project code, instead of Eclipse opening the original source…
hooked82
  • 6,336
  • 4
  • 41
  • 46
29
votes
4 answers

library with bundles dependencies (fat aar)

We build a library that we distribute to our customers. We distribute the raw aar files for them to use. Also we use the raw access API of GitHub to provide a Maven repository. Now to keep things tidy, we split up the library into several…
volkersfreunde
  • 1,095
  • 1
  • 12
  • 22
26
votes
7 answers

Integrate ZXing QR code scanner without installing BarCode Scanner

I am trying to Integrate ZXing QR Code into my android app without installing BarCode Scanner app, I have followed the steps as: 1) Firstly I have downloaded ZXing.zip file and extract it 2)open the ZXing project as an android existing project and…
Kanika
  • 10,648
  • 18
  • 61
  • 81
26
votes
2 answers

Phone and tablet Module vs Android Library

I want to make a separate module so I can share it between projects. The module is going to have android components. So upon creating a new module the options are Phone & Tablet module and Android Library. I wanted to know what's the difference…
Zeyad Gasser
  • 1,516
  • 21
  • 39