Android Studio无法解析来自导入的AAR模块的符号 [英] Android Studio cannot resolve symbols from imported AAR module
问题描述
我的问题是这样的:
我导入了ShowCaseView v5.0.0 AAR,但是当我尝试导入Tutorial.java文件中的类时(您可以看到红色),Android Studio无法识别这些类。 Android Studio唯一可以识别的导入是 com.github.amlcurran.showcaseview.R
。
我也是试图清洁&重建项目,并关闭&重新打开Android Studio,但它没有帮助。
请在将它们复制到项目中之前忽略缺少的XML文件。
$ b
Gradle文件
ShowCaseView -5.0.0> build.gradle:
configurations.create(default)
artifacts.add( ('ShowCaseView-5.0.0.aar'))
我的应用程序的build.gradle :
apply plugin:'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion21.1.2
defaultConfig {
applicationIdcom.giraffeweather
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName1.0
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules .pro'
}
}
}
依赖项{
编译fileTre e(dir:'libs',include:['* .jar'])
compile'com.android.support:appcompat-v7:21.0.3'
compile project(':ShowCaseView-5.0 .0')
}
Android Studio项目的build.gradle:
//顶层构建文件,您可以在其中添加对所有子项目/模块通用的配置选项。
$ b buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle: 1.1.0'
//注意:不要在这里放置应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
}
}
allprojects {
存储库{
jcenter()
gradle设置文件settings.gradle:
include':app',':ShowCaseView-5.0.0'
$ p $我知道有大约零人以这种方式导入AAR文件,我不知道它是否能正常工作。您的结果表明它不会。
要切换到Bintray的JCenter中的图书馆:
1:用
编译'com.github.amlcurran.showcaseview:library:5.0.0替换
compile project(':ShowCaseView-5.0.0')
'
第二步:删除
,':ShowCaseView-5.0.0'
fromsettings.gradle
第三步:删除
ShowCaseView-5.0.0
目录All of the answers in similar questions talk about manunally editting gradle files. But I've used Android Studio to import the AAR file and checked the build.gradle files and they all seem correct.
My problem is this:
I've imported ShowCaseView v5.0.0 AAR but when I try to import the classes in my Tutorial.java file (you can see in red) Android Studio doesn't recognise the classes. The only import that Android Studio recognises is
com.github.amlcurran.showcaseview.R
.I've also tried to clean & rebuild the project, and close & reopen Android Studio but it doesn't help.
P.S. please ignore the missing XML files as that was before I copied them into the project.
Gradle files
ShowCaseView-5.0.0 > build.gradle:
configurations.create("default") artifacts.add("default", file('ShowCaseView-5.0.0.aar'))
My app's build.gradle:
apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.giraffeweather" minSdkVersion 19 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' compile project(':ShowCaseView-5.0.0') }
The Android Studio project's build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } }
The gradle settings file settings.gradle:
include ':app', ':ShowCaseView-5.0.0'
解决方案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')
withcompile 'com.github.amlcurran.showcaseview:library:5.0.0'
Step #2: Delete
, ':ShowCaseView-5.0.0'
fromsettings.gradle
Step #3: Delete the
ShowCaseView-5.0.0
directory这篇关于Android Studio无法解析来自导入的AAR模块的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!