Android Studio not using Gradle jvmArgs when running tests?

陌路散爱 提交于 2021-02-07 12:32:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!