Java – Android Studio automatically updates aar files

Android Studio automatically updates aar files… here is a solution to the problem.

Android Studio automatically updates aar files

Recently considering a move from Eclipse to Android Studio, of course, ran into difficulties. I managed to get through most of them, but only one….

In Eclipse

, I use a library project and then add it to every Eclipse project I want to use it in. When I update the library, the effect is immediately visible in other projects.

In Android Studio, things are different. I managed to generate .aar files and import them into my project. The question is, is there any way to keep the .aar in all these projects updated without having to copy the files again for each project (obviously tedious). If not, is there a way to use library projects like I use them in Eclipse? What I basically want is a way to automatically update my library changes in all projects that use it.

Solution

To reference an existing library project that exists as an Android Studio project, you must add the following line to the settings.gradle file of the project to which you want to link it.

include 'your-lib-project'
project(':your-lib-project').projectDir = new File('path/to/your/lib/project')

Also, you need to add the project to the dependencies in the build.gradle file:

dependencies {
    compile project(':your-lib-project')
}

Related Problems and Solutions