Android Studio cannot resolve symbols from imported AAR module

核能气质少年 提交于 2019-11-28 01:50:56

I know of approximately zero people who import AAR files this way, and I have no idea if it even works properly. Your results suggests that it does not.

To switch to pulling the library from Bintray's JCenter:

Step #1: Replace compile project(':ShowCaseView-5.0.0') with compile 'com.github.amlcurran.showcaseview:library:5.0.0'

Step #2: Delete , ':ShowCaseView-5.0.0' from settings.gradle

Step #3: Delete the ShowCaseView-5.0.0 directory

Recently, I encountered this very same issue. I had an AAR to import into my project. The library was distributed only as AAR. I resolved it by putting my AAR file inside libs/ folder and added the following line in my app module's gradle:

dependencies {
    ...
    compile files('libs/theFirstLib.aar')
}

You can also add multiple AARs like so:

dependencies {
    ...
    compile files('libs/theFirstLib.aar', 'libs/theSecondLib.aar')
}

If you are using Gradle 3.0.0 or higher, you may need to substitue compile with implementation:

implementation files('libs/theFirstLib.aar')

Worked like a charm!

NOTE: Importing an AAR sometimes results to another "cannot resolve symbol" error, which I resolved here when Android Studio and Gradle don't agree.

You need to specify the location of "ShowCaseView-5.0.0.aar" in project's build.gradle file. E.G, the ShowCaseView-5.0.0.aar file is in a folder named "libs" under project's root directory, update you build.gradle file to add following

allprojects {
    repositories {
        flatDir {
            dirs 'libs'
        }
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!