Android 将调试实现添加到gradle会导致测试失败

Android 将调试实现添加到gradle会导致测试失败,android,debugging,testing,Android,Debugging,Testing,将调试实现添加到my gradle(然后同步)会导致测试失败: def fragment_version=“1.2.5” 调试实现“androidx.fragment:片段测试:$fragment\u版本” 这是我的毕业证书: 应用插件:“com.android.application” 应用插件:“kotlin android” 应用插件:“kotlin android扩展” android { compileSdkVersion 29 buildToolsVersion "29.0

将调试实现添加到my gradle(然后同步)会导致测试失败: def fragment_version=“1.2.5” 调试实现“androidx.fragment:片段测试:$fragment\u版本”

这是我的毕业证书: 应用插件:“com.android.application” 应用插件:“kotlin android” 应用插件:“kotlin android扩展”

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
    applicationId "com.micheladrien.fresquerappel"
    minSdkVersion 22
    targetSdkVersion 29
    versionCode 12
    versionName "1.2"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
def navigation_version = '2.3.1'
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
implementation 'il.co.theblitz:observablecollections:1.4.2'
def espressocore_version = '3.3.0'
androidTestImplementation "androidx.test.espresso:espresso-core:$espressocore_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressocore_version"
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation "android.arch.core:core-testing:$lifecycle_version"
def mockito_version = '3.5.5' // For local unit tests on your development machine
testImplementation "org.mockito:mockito-core:$mockito_version" // For instrumentation tests on Android devices and emulators
androidTestImplementation "org.mockito:mockito-android:$mockito_version"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support:support-annotations:24.0.0'
androidTestImplementation "androidx.navigation:navigation-testing:$navigation_version"
def fragment_version = "1.2.5"
debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
}
结果如下: 测试于16:01开始

11/17 16:01:26: Launching 'testOpenSingleFrag...()' on LGE LG-H870S.
App restart successful without re-installing the following APK(s): com.micheladrien.fresquerappel
Running tests

$ adb shell am instrument -w -m    -e debug false -e class         'com.micheladrien.android.fresquerappel.UITest.MainActivityTest#testOpenSingleFragment'     com.micheladrien.fresquerappel.test/androidx.test.runner.AndroidJUnitRunner
Test running failed: Process crashed.
Tests ran to completion.
删除最后两行可以阻止测试崩溃。 由外部测试的应用程序工作正常 有人知道为什么会有这个问题吗?或者任何能够在我的测试文件中执行launchFragmentInContainer()的变通方法

提前感谢您的帮助

编辑:其他有用的信息:我的应用程序只有一个构建变量,那就是调试