[英]Android rebuild project, package org.junit does not exist error
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)
:app:compileDebugUnitTestJavaWithJavac FAILED
Error:Execution failed for task ':app:compileDebugUnitTestJavaWithJavac'
。
编译失败; 有关详细信息,请参见编译器错误输出。
当我运行重建时,错误就是那些。 但是我可以运行我的应用程序而无需重建。
我不使用测试,我不知道它如何进入我的文件夹。
代码是:
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
将此添加到您的build.gradle
dependencies {
...
testCompile 'junit:junit:4.12'
}
当我从另一个项目复制/粘贴文件时,此错误发生在我身上。
关闭Android Studio并重新打开即可解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.