bph bph - 10 months ago 46
Android Question

How to disable android studio unit tests (androidTest)

I have imported an eclipse project into android studio

Somehow it figured out that another one of my eclipse projects contained unit-test code for the imported project

It brought in that code and put it in a src/androidTest dir

I didn't really want it to do that but they are there now and causing the build to fail

Is there a means to turn off the androidTest stuff? So I can concentrate on whether the app actually builds?

Maybe its via a gradle setting? (This is my first exposure to gradle)

Maybe I just need to delete all the androidTest java files but this seems a bit final..


Once you do Rebuilding the project in Android Studio - all the source files in the project are recompiled. Plenty of different tasks start including :compileDebugAndroidTestJavaWithJavac which is causing the build-break, once your Instrumental Tests are not compilable.

enter image description here

Calling for rebuilding in Android Studio is just a UI for passing these tasks to gradle:

Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources]

I.e. there's no obvious way how can it be modified.


  • comment out broken files in androidTest
  • remove/rename androidTest directory
  • build project with Android plugin for Gradle and passing all commands, apart from ones related to InstrumentalTests
  • avoid Making/Rebuilding solution, just add(if it's not exist yet) Android Application configuration and build the app itself, without instrumental tests

I hope, it helps.