1

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

karl
  • 3,544
  • 3
  • 30
  • 46
  • The same problem exists when you use your `~/.gradle/gradle.properties` file to specify `javax.net.ssl.trustStore`. Android Studio just ignores it. Oddly enough it happily stores its proxy settings in that file if you specify them in the Android Studio settings. – cb2 Jan 22 '20 at 21:14
  • Interesting. I ended up having to set the system property at runtime (see my answer), which has worked out fine so far – karl Jan 23 '20 at 22:04

1 Answers1

1

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')

karl
  • 3,544
  • 3
  • 30
  • 46
  • 1
    Thanks! That gave me an idea on how to fix it "globally" as I do not want the `javax.net.ssl.trustStore` to be specific to one repo. I created a `truststore.gradle` file and placed it under `~/.gradle/init.d/` and in that file I added `System.setProperty("javax.net.ssl.trustStore", "path to my truststore")`. Works like a charm from command line so hopefully it will work for AndroidStudio as well. – cb2 Oct 07 '20 at 09:41
  • I can confirm that the trick worked for Android Studio as well :) – cb2 Oct 07 '20 at 12:13