Search code examples
android-studiogradlew

Use modified gradlew when building from Android Studio


I have an Android app that I'm trying to build from both the command line and from within Android Studio. As part of customization, I've modified the DEFAULT_JVM_OPTS in the gradlew file that Studio automatically creates. (Specifically, I'm adding -Djavax.net.ssl.trustStore)

However, I don't think they're being picked up when running from within Studio (for example, clicking the Run button). How can I make the same modifications within Studio? I'd particularly like it if I could make this change in one place and have it be picked up by both command line builds and Studio builds.

Edit: I've found a solution (see below), but it's a workaround that may not work for every situation. I'd love it if there were a way to have Android Studio pick up changes made in gradlew


Solution

  • I've been able to work around this by setting the system properties in my build.gradle, as in https://stackoverflow.com/a/43486698/1139908:

    System.setProperty('javax.net.ssl.trustStore', '.keystore') System.setProperty('javax.net.ssl.trustStorePassword', 'changeit')