2017-09-06 92 views
1

我想在android studio中構建一個應用程序,並且遇到最近纔出現的錯誤。據我所知,我沒有改變任何設置或修改任何可能導致錯誤發生的系統文件。我已經嘗試重新安裝android studio但錯誤仍在發生,所以我開始認爲這是一個編碼問題。錯誤如下:錯誤:包android android.test不存在

Gradle task[clean, :app:generateDebugSources,:app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :appcompileDebugSources, :app:complieDebugSources, :app: compileDebugAndroidTestSources, :app:compileDebugUnitTestSources] 
    C:\Users\Stuart\Documents\TourApp\App\src\androidTest\java\com\example\android\tourapp\ExampleInstrumentedTest.java 
error: package android.support.test does not exist 
error: package android.support.test.runner does not exist 
error: package android org.junit does not exist 
error: package android org.junit.runner does not exist 
error: package android org.junit does not exist 
error: cannot find symbol class RunWith 
error: cannot find symbol class Test 
error: cannot find symbol variable InstrumentationRegistry 
Execution failed for task ':app:compileDebugAndroidTestJavaWithJavac'. 
Compilation failed; see the compiler error output for details. 

任何想法可能導致這種情況?

Android Studio Error

回答

1

嘗試增加以下行下依賴關係部分在應用程序/的build.gradle文件

dependencies { 

    testCompile 'junit:junit:4.12' 
    //androidTestCompile 'junit:junit:4.12' 
} 

你也可以使用androidTestCompile 'junit:junit:4.12'作爲備用。

相關問題