Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how update local aar package sources

I created two Android Studio applications. One of them is aar library. I used this aar library in second application. I added aar library by using File->New->New Module->Import AAR/JAR Packages option. after that I can see decompiled sources of my aar library. When I update aar library I copy and paste new aar file to my application project folder. But this time Android Studio shows older decompiled sources. But compile new source successfully. How can I update decompiled sources in Android Studio ? when I import aar file implementation project(':app-debug') line was added my build.gradle file.

I am using Android Studio 3.0.1

my solution

the only way I can find to update local sources is clicking Sync Project with Gradle Files button after updating aar/jar file.

like image 652
utarid Avatar asked Nov 29 '17 14:11

utarid


People also ask

Do AAR file is generated file?

Android Studio can be used to create an Android archive file (*. aar) that can contain classes and methods that make use of Android classes and related files. Like creating the Jar file, an Android project must be created first, then the Android library module can be created and added.

Where is AAR file located?

If you have a module defined as an android library project you'll get . aar files for all build flavors (debug and release by default) in the build/outputs/aar/ directory of that project.

Is AAR same as jar?

The main difference is aar is splitted inside android to jar. If your app will be used only in user app only in android studio then aar is preferred. If you are planning for app to communicate with c/c++ compiled lib.so file jar is preferred.


2 Answers

I was having the same issue, had tried every form of including my local aar in my project, tried every method of rebuilding, invalidating caches etc, but I was still having the problem where changes in my local aar were not available after updating the file in the libs folder.

The only thing that worked for me was this:

  1. Comment out the implementation files('../libs/yourlib.aar') line in gradle
  2. Sync gradle
  3. Update yourlib.aar in the libs folder
  4. Uncomment the implementation files('../libs/yourlib.aar') line in gradle
  5. Sync again
  6. Build project

Now the changes in yourlib.aar should be available in your project. If you have this lib included in multiple modules I am guessing you'll have to do it for each module. Not ideal, but I spent at least 5 hours on this issue and these steps were the only way I could seemingly force the changes. I am guessing that removing the library from the gradle file and then syncing will force it to pick up the new one when it is added again.

like image 158
Shayla Sawchenko Avatar answered Oct 05 '22 16:10

Shayla Sawchenko


I had the same issue and solved it very quickly doing the following:

  • Look in your project /.idea/libraries/ folder for Gradle__artifacts_[subproject].xml
  • Delete this file
  • In Android Studio, go to File->Sync Project with Gradle Files

This is for an AAR included as a project (which is how it is included when you use File->New->New Module...->Import .JAR/.AAR Package).

like image 45
Regular User Avatar answered Oct 05 '22 15:10

Regular User