gpt4 book ai didi

java - 在 ExampleInstrumentedTest.java 文件中获取错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:07:52 26 4
gpt4 key购买 nike

我的项目运行成功,预计当我清理并重建项目时得到这个错误

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources]
D:\Gonna Projects\DoctorApps\app\src\androidTest\java\in\doctormobileapps\doctorapps\ExampleInstrumentedTest.java
Error:(4, 28) error: package android.support.test does not exist
Error:(5, 35) error: package android.support.test.runner does not exist
Error:(7, 17) error: package org.junit does not exist
Error:(8, 24) error: package org.junit.runner does not exist
Error:(11, 24) error: package org.junit does not exist
Error:(18, 2) error: cannot find symbol class RunWith
Error:(20, 6) error: incompatible types: Test cannot be converted to Annotation
Error:(23, 30) error: cannot find symbol variable InstrumentationRegistry
Error:Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 4.834 secs
Information:9 errors
Information:0 warnings
Information:See complete output in console

有没有人可以告诉我我做错了什么?

最佳答案

您似乎没有将 Junit-Package 添加到模块的 build.gradle 文件中。只需将它添加到 dependencies block 中,它应该可以工作:

androidTestCompile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'

关于java - 在 ExampleInstrumentedTest.java 文件中获取错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40043216/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com