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
0
votes
1 answer

import my library in app

I developed android library and I tried import this library in other app "compileOnly" dependencies { compileOnly 'xxx.xxx.xxx:xx-xx-xx:1.0' } but gradle show me: "Android dependency 'xxx-xxx-xxx:xx-xx-xx:1.0' is set to compileOnly/provided…
0
votes
1 answer

Android Studio project runs fine but build APK fails due to "multiple dex files..."

Using Android Studio 3.0, I have an Android application project with the following layout: app | - lib-foo - lib-bar So I have an application module, using two library modules called lib-foo and lib-bar, respectively. Now, here comes the…
JHH
  • 8,567
  • 8
  • 47
  • 91
0
votes
2 answers

connection timed out error in online mode and could not open file in offline mode - android studio

repositories { maven { url "https://jitpack.io" } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile…
0
votes
0 answers

How to publish single android AAR dependent on internal modules and 3rd party libs

Problem statement We need to deliver an android SDK in form of single AAR package wherein our code internally divided into various sub-modules and also has dependencies on external libs(AARs). I'm stucked in the way that how to package the modules…
0
votes
1 answer

Firebase Database from a library - mixed with app's Firebase database

I'm building a library that is using Firebase database. when i'm taking the exported .aar and importing it via another app - i get the following error: FirebaseAuthException: This operation is not allowed the original app didnt allow the firebase…
0
votes
0 answers

Private Activity (Fragments, etc) in Android Library

I need create my own "SDK" for consume some features of my API... But, for security reasons, I need create a "private flow" (Activity, Layout, etc) to guarantee users privacy (users can put CreditCard info, etc)... It's possible create a private…
0
votes
1 answer

Adding a C++ AAR library into Android Studio?

A C++ library which was converted to .AAR (Not by me) to use with Android Studio . I was able to add the aar file inside lib folder and was able to sync successfully using gradle . I am well aware that c++ library can be only accessed threw JNI .…
0
votes
1 answer

Error when putting google service plugin in library module

when I place the apply plugin: 'com.google.gms.google-services' in library module in app level it show an error like 'Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension' So I removed…
0
votes
0 answers

Exporting a populated Room database so that it can be consumed

I have have created and populated a Room database. What I would like to do is to export the database and include it in an Android library module, along with the supporting DTO's, so that it can be consumed by an app. Is this possible and if so, how…
Rhisiart
  • 1,046
  • 12
  • 13
0
votes
1 answer

ObjectBox create object entity with map and custom types

How can I support object like that with ObjectBox lib: @Entity public class A implements Serializable { private Map aMap; } I'm not sure if should I use objectBox converter? I found some threads which mention that ObjectBox…
motis10
  • 2,484
  • 1
  • 22
  • 46
0
votes
1 answer

How to support multiple RealmMigrations

We have multiple android libraries that are independent to each other & relies on core library. Core library has CoreRealmManager, which is responsible for all realm operations. app | --- lib-module-a | \-- lib-module-c | \--…
VenomVendor
  • 15,064
  • 13
  • 65
  • 96
0
votes
1 answer

Starting library Activity from another library project

I have a library(LIB2) project that depends on another library(LIB1) project that I compiled as AAR and uploaded on Archiva. When I try to start a LIB1 Activity from LIB2 by using: startActivity(new Intent(HelperActivity.this,…
xuzhian
  • 1
  • 3
0
votes
1 answer

Using the same custom library in projects with different SDK min version

I have a custom library with several utility classes. I used it so far in a single project with min SDK 21. Now, I want to reuse one of the classes in another project, which has min SDK 14. The class code is fine with version 14, but Gradle does…
ilomambo
  • 8,290
  • 12
  • 57
  • 106
0
votes
1 answer

Can I publish a library for Android with dependecies on Android SDK as JAR?

I'm publishing my first library for Android. Most of the guides and tutorials out there show how to publish the library as AAR, but I came to wonder whether I need to do it this way if I don't have manifest entries, resources, etc. My library has…
Vasiliy
  • 16,221
  • 11
  • 71
  • 127
0
votes
1 answer

Is it better to upload an android library to GitHub than keeping it inside the project?

I'm really new with android developing. But I know how to upload a library to GitHub and include it in an android project. Recently, I'm working on some android apps, and I realized that I need to use some layouts and classes for all the apps. So, I…