How to force Android Studio 3.1.3 to load the latest local jar/aar library
The problem
Starting from at least version 3.1.3 of Android Sutdio, the local jar/aar library refresh mechanism seems to be broken.
The situation is I have a local aar library named my-lib.aar
, which is my product, placed under $project_root/app/libs
. Whenever I change the code I will compile a new aar library and replace the old one with the new. It was awesom before Android Studio 3.0.0, the IDE can recognize the library has changed and load it automatically, so what I need to do is just hiting the run
button then a new app with my new library will get built and run. However, with 3.1.3 and it is still broken in the latest 3.1.4 released August 2018, the aforementioned process will end up with the app built with the old library.
The fix
After experimenting a while, the easiest workaround is to delete the IDEA cache config file for that library, which is $project_root/.idea/libraries/Gradle__your_package_name_version.xml
. Optinally, you can also delete cache file at ~/.gradle/caches/transforms-1/files-1.1/your_lib_name.aar
, which just eat up a bit of your storage but won’t mess up your build. Tested with MacOS, should also work for Linux OS.