android studio 解决 junit 错误的问题
16lz
2022-07-26
提示错误信息如下:
Error:A problem occurred configuring project ':app'.
> Could not download junit.jar (junit:junit:4.12)
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar'.
> Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar'.
> Connection to https://jcenter.bintray.com refused
原因是在APP 的build.gradle中的
dependencies { ...... testCompile 'junit:junit:4.12' ......... }编译测试用例时编译了'junit:junit:4.12;把该行去掉;编译出现错误如下:D:\android_work\MyApplication\app\src\test\java\com\example\gchen\myapplication\ExampleUnitTest.java
Error:(3, 17) error: package org.junit does not exist
Error:(5, 24) error: package org.junit does not exist
Error:(11, 6) error: cannot find symbol class Test
Error:(13, 9) error: cannot find symbol method assertEquals(int,int)
原因是没有找到org.junit这个包,这个包的位置在android studio 目录下的
gradle\gradle-2.10\lib\plugins\junit-4.12.jar;把这个包复制到项目APP的libs目录下即可;
更多相关文章
- android EditText设置不可写
- android ndk编译x264开源(用于android的ffmpeg中进行软编码)
- Android(安卓)Activity的启动
- [android]编译时出现/usr/bin/ld: skipping incompatible /usr/l
- 编译android的linux内核
- Android(安卓)命令行编译、打包生成apk文件
- APP开发实战94-Vector静态图的使用
- Android热更新框架Tinker无法更新?
- Android(安卓)开发中的倒计时