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
19
votes
9 answers

Gradle: pros/cons adding dependencies

What are some pros/cons adding dependencies in build.gradle, instead of adding them as dependent libraries? dependencies { compile project(':library') ... compile 'com.stackoverflow.android:some-great-library:1.0' ... } While…
19
votes
3 answers

How to override drawables defined in an Android Library Project?

I have two Android applications with a similar functionality but different drawables and layouts. I'd like to put all the code and resources in a library project and override some of the drawables and layouts in the two applications that would…
Eran
  • 387,369
  • 54
  • 702
  • 768
18
votes
5 answers

Android project referencing "normal" java project in eclipse since sdk tools update 17

Since the latest android sdk i am unable to run my android applications from eclipse anymore because they cant find classes which i have in other eclipse projects, which are references via the 'normal' build path. this has definitely worked before.…
clamp
  • 33,000
  • 75
  • 203
  • 299
18
votes
7 answers

NoClassDefFoundError on external library project for Android

I use eclipse for Google Android development. I've created a library project ([x] Is Library in the Android-settings), which includes an external jar-file (Referenced Libraries). This library project are referenced in another Project (the actual…
f00860
  • 3,486
  • 7
  • 41
  • 59
18
votes
1 answer

Failed to resolve project: Android library and Java library module dependency

I'm trying to create a project which includes an Android library and a Java library in Android Studio (3.1). The Java library depends on the Android library. Both are modules in my project like this: MyProject |-android |-java Both appear in…
Sir Codesalot
  • 7,045
  • 2
  • 50
  • 56
17
votes
5 answers

Android / Execution failed for task checkDebugAarMetadata / A failure occurred while executing CheckAarMetadataWorkAction

TL'DR: In this Android Kotlin library I updated from Gradle 5.6.4 to 6.6.1 (commit d5d8d2). Now I cannot build a project depending on the aar anymore. Test setup I build and deploy the aar to mavenLocal ... $ ./gradlew clean :roadsigns:assemble $…
JJD
  • 50,076
  • 60
  • 203
  • 339
17
votes
3 answers

How to reference a drawable from a library project into a main project's layout in android?

I have a android library project and reusable drawable resources in it. Lets say package name is: com.vijay.mylib; Then i have a main project and it uses the above library project. Lets say its package name is:com.vijay.myproject. Consider that…
Vijay Krishna
  • 888
  • 2
  • 8
  • 20
17
votes
3 answers

How to implement .get feature with FutureTask or BackgroundTask using android?

I am making one android library. And in my library i want to allow a user to perform a particualar task either in background or in main thread. I want to do something like this . 1st Scenario MyLibabry.with(context) .performSomeTask() …
Moinkhan
  • 12,732
  • 5
  • 48
  • 65
17
votes
2 answers

How to get the application id from inside a library using my project?

How can I get the application ID from the application using my library using gradle? Or any way to put it inside a xml file.
kaneda
  • 5,981
  • 8
  • 48
  • 73
17
votes
3 answers

Duplicate files at the same path inside the APK

I have an application using some librarries. The problem is that when I am trying o export the apk file, I am getting the "Duplicate files at the same path inside the APK". Here is the log: org.eclipse.core.runtime.CoreException: Duplicate files at…
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
17
votes
2 answers

Android - Having Provider authority in the app project

An android library project contains a few providers whose authority is defined like the following in a contract class : public static final String CONTENT_AUTHORITY = "my.com.library.providers.tester"; private static final Uri BASE_CONTENT_URI =…
500865
  • 6,920
  • 7
  • 44
  • 87
17
votes
3 answers

Eclipse will not recognize project as library (ActionBarSherlock/ViewPagerIndicator)

I'm trying to get ActionBarSherlock and the ViewPagerIndicator libraries set up for my projects, but I seem to be running into a few issues. I sent Jake Wharton (The developer) a few messages earlier about it, and got a few replies but couldn't get…
16
votes
5 answers

Android Library assets folder doesn't get copied

I am creating an Android library and it has an assets folder with images. When I use it in another project the assets doesn't get copied. Anyone else had this issue?
Macarse
  • 91,829
  • 44
  • 175
  • 230
16
votes
4 answers

android import ressources from library project

is it possible to use ressources like strings that are defined in library projects in the application-projects? if so, how? because i cant seem to resolve the strings i would like to resolve like this: String title = "sample"; int id =…
clamp
  • 33,000
  • 75
  • 203
  • 299
16
votes
2 answers

Set different theme for library project in android

In an android project which consists of a library project, I need to have a different theme set in manifest for main app and library. Like I need to set below theme in the main project