Android Studio cannot resolve symbols from AAR
aar, android, android-studio
Solution
I guess the problem was Android Studio and Gradle did not agree. Here are three solutions that worked for me (after hours of tests). If one option does not work for you, try the next.
Option 1
- Gradle -> Refresh All Gradle Projects
Option 2
- Gradle -> Refresh All Gradle Projects
- Remove 'build' directories from project
- Remove .gradle cache from C:\Users\YOUR_USER_NAME\.gradle\caches\transforms-1\files-1.1\* (only delete the few latest folders)
- Build -> Clean Project
Option 3 (this will restart your Android Studio)
- File -> Invalidate Caches / Restart
- then choose Invalidate and Restart
- Gradle -> Refresh All Gradle Projects
Problem
My question has the same problem as Issue with using .AAR file in other project. But I want to add more details. Hence the new question. I am also aware of solutions such as this Android Studio cannot resolve symbols from imported AAR module but the answers aren't exactly what I am looking for. I can add my AAR file into my project without problem either by adding it in libs/ folder or adding as new AAR module. The problem happens when the AAR authors give an updated AAR (because they changed something in their public API i.e. adding new parameter in one of the old methods). Android Studio can't seem to pickup the changes. In the old library, I had this method call: ``` library.showText("hello"); ``` Authors released a new API with update to the same method, and should be called as: ``` library.showText("hello", 5000); // added timeout param ``` When I CTRL+click the method, it takes me to the old class that has the method located in C:\Users\MyUser\.gradle\caches\transforms-1\files-1.1\library.aar\...\old.class. I think this is the problem why I get "cannot resolve symbols" error. How do I fix this?