“android.enableUnitTestBinaryResources”已弃用[重复]

2024-05-05

我刚刚更新了我的 Android Studio,现在当我构建我的项目时,我收到此错误:

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

这是我的 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
}

如果您能帮助我,我将不胜感激。


我知道问题出在哪里了。从 Android studio 3.3+ 开始,无需将以下代码添加到“gradle.properties”文件中。

android.enableUnitTestBinaryResources=true

所以必须将其删除。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

“android.enableUnitTestBinaryResources”已弃用[重复] 的相关文章

随机推荐