“无法解决:sdk-release:”这是一个aar文件

时间:2017-10-28 17:41:36

标签: android sdk

之前我问了一个关于我的项目的问题,但仍然需要帮助......

Android Studio 3 gradle sync issue

现在我还有另外一个我无法弄清楚的问题。当我尝试构建我的项目时,我收到此错误:

  

错误:无法解决:: sdk-release:

我的 sdk-release.aar 文件位于 projectFolder> libs> aar 以及 sdk-release

这是什么错误,我该如何解决?

我的 build.gradle 代码现在就像这样

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'

    }
}

repositories {
    mavenCentral()
    mavenLocal()
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId 'com.kofax.sdk.samples.easysnap'
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName '1.0'
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    buildTypes {
        release
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    lintOptions {
        abortOnError false
    }
}

configurations.all {
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {

    def sdkRef

    project.getRootProject().allprojects.each { proj ->
        if (proj.name.toLowerCase().equals('sdk')) {
            sdkRef = proj;
            return true;
        }
    }

    if (sdkRef) {
        println "SDK present in project; using project reference as dependency"
        compile sdkRef
    } else {
        println "SDK is not present in project; dependency reference"

        repositories {
            flatDir { dirs 'libs' }
        }

        implementation (name: 'sdk-release', ext: 'aar')
    }

    compile fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:23.4.0'

}

1 个答案:

答案 0 :(得分:-1)

更改代码:

implementation (name: 'sdk-release', ext: 'aar')
compile fileTree(dir: 'libs', include: ['*.jar'])

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.aar'])

implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])