“android.enableUnitTestBinaryResources”已被弃用。

40

我刚刚更新了我的Android Studio,现在当我构建我的项目时,我会得到以下错误:

选项'android.enableUnitTestBinaryResources'已被弃用。当前默认值为“false”。它已从当前的Android Gradle插件版本中移除。单元测试功能的原始资源已被删除。受影响的模块:app

这是我的build.gradle(:app)文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'androidx.navigation.safeargs.kotlin'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.oniktech.newmixnote"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility rootProject.ext.java_version
        targetCompatibility rootProject.ext.java_version
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        String sharedTestDir = 'src/test/java'
        test {
            java.srcDir sharedTestDir
        }
        androidTest {
            java.srcDir sharedTestDir
        }
    }

    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }


    externalNativeBuild {
        ndkBuild {
            path '/src/main/jni/Android.mk'
        }
    }

}


dependencies {


    def camerax_version = "1.0.0-alpha02"
    implementation "androidx.camera:camera-core:${camerax_version}"
    implementation "androidx.camera:camera-camera2:${camerax_version}"


    implementation 'androidx.fragment:fragment:1.1.0-rc02'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'


    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'


    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    kapt 'com.github.bumptech.glide:compiler:4.9.0'


    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test:rules:1.2.0'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    testImplementation 'junit:junit:4.12'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0'
    implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'


    implementation 'com.github.chrisbanes:PhotoView:2.3.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.patrickpissurno:ripple-effect:1.3.1'
}

我删除了以下行,但它没有解决问题:

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

这是我的gradle.build(:project)文件:

buildscript {
    ext.kotlin_version = '1.3.50'
    ext.java_version = JavaVersion.VERSION_1_8

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha11"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenLocal()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

如果你能帮我这个忙的话,我将不胜感激。


1个回答

128

我弄清楚问题所在了。从Android Studio 3.3+开始,不需要将以下代码添加到"gradle.properties"文件中:

android.enableUnitTestBinaryResources=true

因此,这行代码必须删除。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接