Android studioのAndroid JUnit 4ユニットのテスト注記エラーとrecyclerview-v 7バージョンの競合

2554 ワード

bulid.gradleのdependenciesの依存jarパケットエラーrecyclerview-v 7
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
理由:RecyclerViewコントロールに依存するandroid-support-v 4パッケージのバージョンが一致しないため、プロジェクト自体がappcompat依存を使用している(appcompatにはandroid-support-v 4.jarが含まれている)ため、このsupport-v 4とRecyclerView依存のsupport-v 4はバージョンではない
解決策:
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
 v7  v4        

junit 4ユニットテスト(プログラムにテストの開始とjarパッケージのインポートを伝えるだけですが、エラーが発生することがあります)
 1. AndroidManifest.xml、このプロファイルで

 <uses-library android:name="android.test.runner" />

 2. 在build.gradle module:appというプロファイルで
//運転時の統合テスト環境(正確ではありませんが、自動車のエンジンのようです)
defaultConfigにtestInstrumentationRunner"android.support.test.runner.Android JUnitRunner"を追加
dependenciesに追加
//    ,         
androidTestCompile 'junit:junit:4.12'
androidTestCompile ('com.android.support.test:runner:0.5')
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2')