【Android】 リモートリポジトリに繋がらない環境でJUnitを実行する
ネットワーク環境に問題がないときは、Googleのページのやり方で設定すればJUnitの環境設定は簡単だけど、Proxyなどでmaven centralに繋がらない場合の対処法
jarファイルのダウンロード
リモートリポジトリに繋がらないので、jarファイルをlibsフォルダに置いてコンパイルする
- maven centralのページからjunit-4.12.jarをダウンロード
- JUnitのPOMのdependencyを見るとhamcrest-coreへの依存があるのでこちらもダウンロード
<dependencies> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> <version>1.3</version> </dependency> </dependencies>
- ダウンロードしたjarファイルをlibsフォルダにコピー
build.gradle
compile fileTree(dir: 'libs', include: '*.jar', excludes: ['junit-4.12.jar', 'hamcrest-core-1.3.jar']) testCompile files('libs/junit-4.12.jar') testCompile files('libs/hamcrest-core-1.3.jar')