Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error:package android support.test does not exist

I am trying to build an app in android studio and I am encountering an error which has only started to come up recently. As far as I am aware I have not changed any settings or amended any system files which would cause the error to happen. I have tried reinstalling android studio but the error is still happening so I am starting to think it is a coding issue. The error is below:

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.

Any ideas what could be causing this?

Android Studio Error

like image 977
Ropenfold Avatar asked Sep 06 '17 11:09

Ropenfold


1 Answers

Try adding following lines under dependencies section in app/build.gradle file

dependencies {

     testImplementation 'junit:junit:4.12'
     //androidTestCompile 'junit:junit:4.12'
}

Also, you can use androidTestCompile 'junit:junit:4.12' as an alternate.

like image 95
PEHLAJ Avatar answered Oct 09 '22 23:10

PEHLAJ