其他分享
首页 > 其他分享> > Android Studio无法解析导入的AAR模块中的符号

Android Studio无法解析导入的AAR模块中的符号

作者:互联网

类似问题中的所有答案都谈论了manderally编辑gradle文件.但我已经使用Android Studio导入AAR文件并检查了build.gradle文件,它们看起来都是正确的.

我的问题是:

我已经导入了ShowCaseView v5.0.0 AAR但是当我尝试在我的Tutorial.java文件中导入类时(你可以看到红色),Android Studio无法识别这些类. Android Studio识别的唯一导入是com.github.amlcurran.showcaseview.R.

我也尝试过清洁&重建项目,并关闭&重新打开Android Studio,但它没有帮助.

附:请忽略丢失的XML文件,就像我将它们复制到项目之前一样.

Gradle文件

ShowCaseView-5.0.0>的build.gradle:

configurations.create("default")
artifacts.add("default", file('ShowCaseView-5.0.0.aar'))

我的应用程序的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')
}

Android Studio项目的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()
    }
}

gradle设置文件settings.gradle:

include ':app', ':ShowCaseView-5.0.0'

解决方法:

我知道大约有零人以这种方式导入AAR文件,我不知道它是否正常工作.你的结果表明它没有.

要切换到从Bintray的JCenter中提取库:

步骤1:用编译’com.github.amlcurran.showcaseview:library:5.0.0’替换编译项目(‘:ShowCaseView-5.0.0’)

步骤2:从settings.gradle中删除’:ShowCaseView-5.0.0′

步骤3:删除ShowCaseView-5.0.0目录

标签:android,android-studio,gradle,aar,showcaseview
来源: https://codeday.me/bug/20190927/1824815.html