本文介绍了Android重建专案,套件org.junit不存在错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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'

.

当我进行重建时,会出现那些错误.但是我可以运行我的应用程序而无需重建.

When i run rebuild, errors are those. But i can run my appwithout rebuild.

我不使用测试,我不知道它如何进入我的文件夹.

I dont use test, i dont know how it came to my folders.

代码是:

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

Add this to your build.gradle

dependencies {
    ...
    testCompile 'junit:junit:4.12'
}

这篇关于Android重建专案,套件org.junit不存在错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:25