不推荐使用“android.enableUnitTestBinaryResources" [英] 'android.enableUnitTestBinaryResources' is deprecated
问题描述
我刚刚更新了我的 Android Studio,现在当我构建我的项目时出现这个错误:
I just updated my Android Studio and now when I build my project I get this error:
不推荐使用android.enableUnitTestBinaryResources"选项.这当前默认值为假".它已从当前中删除Android Gradle 插件的版本.单元测试的原始资源功能被删除.受影响的模块:app
The option 'android.enableUnitTestBinaryResources' is deprecated. The current default is 'false'. It has been removed from the current version of the Android Gradle plugin. The raw resource for unit test functionality is removed. Affected Modules: app
这是我的 build.gradle(:app)
Here is my 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'
}
我删除了以下行,但没有解决问题:
I removed the below line but it didn't fix the problem:
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
这是我的 gradle.build(:project):
And here is my 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
}
如果您能帮我解决这个问题,我将不胜感激.
I would be appreciated if you could help me with this.
推荐答案
我想出了问题所在.从 Android Studio 3.3+ 开始,无需将以下代码添加到gradle.properties"文件中.
I figured out what the problem is. From Android studio 3.3+ there is no need to add the code below to "gradle.properties" file.
android.enableUnitTestBinaryResources=true
所以它必须被移除.
这篇关于不推荐使用“android.enableUnitTestBinaryResources"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!