问题
I have an Android library with a JUnit test that only passes if it is run with the -noverify
flag passed to the JVM (I believe because of this). The test will pass if it is run from the command line as long as I tell Gradle to pass that flag by adding this to my build.gradle file:
android {
testOptions.unitTests {
all {
jvmArgs '-noverify'
}
}
}
I thought that Android Studio would pick that up and use that flag to run the tests as well, but that does not seem to be the case. In order to get the test to pass in Android Studio I seem to need to edit the run configuration for the test to include the -noverify
flag:
Obviously that change by itself (i.e., without specifying the -noverify
flag as a jvmArg in the build.gradle file) does not allow Gradle to run the test successfully outside of Android Studio.
Is there a way to allow Android Studio to pick up the jvmArgs specified in the build.gradle file so that it is not necessary to also update the run configuration for the test in order to get the test to pass both when run directly from Gradle and when run from Android Studio?
Android Studio: 3.0.1, Android Gradle Plugin: 3.0.1, Gradle: 4.5
来源:https://stackoverflow.com/questions/49320483/android-studio-not-using-gradle-jvmargs-when-running-tests