質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Gradle

Gradleは、ビルド自動化ツールです。 ソフトウェアパッケージやドキュメント、 または実際に何か他の種類のプロジェクトの構築、テスト、公開、展開などを自動化が出来ます

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

Q&A

解決済

1回答

2968閲覧

android studioでandroidTestのエラーを解決できない

kotatsu828

総合スコア6

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Gradle

Gradleは、ビルド自動化ツールです。 ソフトウェアパッケージやドキュメント、 または実際に何か他の種類のプロジェクトの構築、テスト、公開、展開などを自動化が出来ます

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

0グッド

0クリップ

投稿2020/04/18 14:33

#前提・実現したいこと
プロジェクトを作成した際にデフォルトであったと思われる、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'
}

上記の対応によりエラー内容が若干変化したが、実行できず

#補足
解決方法とエラー内容も含めて教えていただけると幸いです。
よろしくお願い申し上げます。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kakajika

2020/04/25 04:03

truthを入れようと試みた時に同じようなエラーに遭遇しました。 androidTestImplementation.exclude ...の記述は無くして、衝突が起きているライブラリをimplementation '...' でバージョン指定するとエラーを回避できたと思います。結局truthは使わずにkotlintest-assertionsを導入してしまったので記憶が曖昧ですが、ご参考までに。
kotatsu828

2020/04/27 11:40

おっしゃる通りにしたらテスト実行できました! kotlintest使おうと思います
kotatsu828

2020/04/27 13:52

ありがとうございます!!
kakajika

2020/04/27 14:23

それは何よりです ???? このページを見る人のためにも、回答に解決策を書いて自己解決としてください。
guest

回答1

0

自己解決

androidTestImplementation.exclude ...の記述を無くし
androidTestImplementation ('androidx.test.ext:truth:1.2.0')
androidTestImplementation ('com.google.truth:truth:1.0')を
testImplementationに変更したところテストpassしました
truthは使わないことにしました

投稿2020/04/28 08:33

kotatsu828

総合スコア6

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問