#前提・実現したいこと
プロジェクトを作成した際にデフォルトであったと思われる、androidTestパッケージのテストを実行してもエラーになり、同様のエラーの解決がstackoverflow等に載っていたので、実践してみたが解決できませんでした。
#発生している問題・エラーメッセージ
Cannot find a version of 'org.checkerframework:checker-compat-qual' that satisfies the version constraints:
buildOutput
1Could not determine the dependencies of task ':app:processDebugAndroidTestManifest'. 2> Could not resolve all task dependencies for configuration ':app:debugAndroidTestRuntimeClasspath'. 3 > Could not resolve org.checkerframework:checker-compat-qual:{strictly 2.0.0}. 4 Required by: 5 project :app 6 > Cannot find a version of 'org.checkerframework:checker-compat-qual' that satisfies the version constraints: 7 Dependency path 'Gotcha2:app:unspecified' --> 'com.google.truth:truth:1.0' --> 'org.checkerframework:checker-compat-qual:2.5.5' 8 Constraint path 'Gotcha2:app:unspecified' --> 'org.checkerframework:checker-compat-qual:{strictly 2.0.0}' because of the following reason: debugRuntimeClasspath uses version 2.0.0 9
#該当のソースコード
kotlin
1@RunWith(AndroidJUnit4::class) 2class ExampleInstrumentedTest { 3 @Test 4 fun useAppContext() { 5 // Context of the app under test. 6 val appContext = InstrumentationRegistry.getInstrumentation().targetContext 7 assertEquals("com.example.gotcha2", appContext.packageName) 8 } 9}
#使っているツールのバージョンなど補足情報
Gradle.app
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'realm-android' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.example.gotcha2" minSdkVersion 26 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } testOptions{ unitTests.returnDefaultValues = true } useLibrary 'android.test.runner' useLibrary 'android.test.base' useLibrary 'android.test.mock' } repositories { maven { url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0' //noinspection GradleCompatible implementation "com.android.support:design:28.0.0" implementation 'androidx.core:core-ktx:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'com.github.bumptech.glide:glide:4.9.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4' implementation 'com.google.guava:guava:28.0.1-android' //androidTest系 androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:rules:1.2.0' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation ('androidx.test.ext:truth:1.2.0') androidTestImplementation ('com.google.truth:truth:1.0') // Optional -- Hamcrest library androidTestImplementation 'org.hamcrest:hamcrest-library:1.3' // Optional -- UI testing with Espresso androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0' androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.2.0' // Optional -- UI testing with UI Automator androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' androidTestImplementation("org.mockito:mockito-android:2.24.5") implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.uphyca:stetho_realm:2.1.0' } configurations { androidTestImplementation.exclude module: 'guava' androidTestImplementation.exclude module: 'error_prone_annotations' androidTestImplementation.exclude module: 'checker-qual' } apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
Gradle.module
buildscript { ext.kotlin_version = '1.3.71' repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.6.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.3' classpath "io.realm:realm-gradle-plugin:6.0.2" } } allprojects { repositories { google() jcenter() } } subprojects { project.configurations.all { exclude group: 'com.google.guava', module: 'failureaccess' resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "26.1.0" } if('guava' == details.requested.name) { details.useVersion '23.6-android' } } } } task clean(type: Delete) { delete rootProject.buildDir }
#実践したこと
・関係ありそうなものを最新のバージョンに変更
・gradle(module)にsubproject{}追加
・implementation 'com.google.guava:guava:28.0.1-android'追加
・Gradle(app)にconfigurations{}追加
configurations {
androidTestImplementation.exclude module: 'guava'
androidTestImplementation.exclude module: 'error_prone_annotations'
androidTestImplementation.exclude module: 'checker-qual'
}
上記の対応によりエラー内容が若干変化したが、実行できず
#補足
解決方法とエラー内容も含めて教えていただけると幸いです。
よろしくお願い申し上げます。
回答1件
あなたの回答
tips
プレビュー