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..
Put this code into your app's gradle script:
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
//this is for speed up build
task.enabled = false
}
if(task.name.contains("Test"))
{
//this is what you need
task.enabled = false
}
}
When gradle add a task, this code ll check tasks name. if this task is 'lint' (check here) which is not need every build. if this task has a 'Task' word, we can skip if we want.
:app:preDebugAndroidTestBuild SKIPPED
:app:compileDebugAndroidTestAidl SKIPPED
:app:processDebugAndroidTestManifest SKIPPED
:app:compileDebugAndroidTestRenderscript SKIPPED
:app:generateDebugAndroidTestBuildConfig SKIPPED
:app:generateDebugAndroidTestResValues SKIPPED
:app:generateDebugAndroidTestResources SKIPPED
:app:mergeDebugAndroidTestResources SKIPPED
:app:splitsDiscoveryTaskDebugAndroidTest SKIPPED
:app:processDebugAndroidTestResources SKIPPED
:app:generateDebugAndroidTestSources SKIPPED
I dont know what these tasks are. But when i skip on my project doesnt effect anything but speed (not much because i dont have test files) which is a pain on gradle build system.
I hope, this ll help you.
Someone might find this useful: If you're using JUnit
there's an @Ignore
command you can put on a test method to ignore the entire test method.
Example:
@Ignore("This test will be ignored")
@Test
public void my_test_method() {
// test code here...
}
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.
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.
Workarounds:
I hope, it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With