Reputation: 71
I need your help. I have to make an Android app in a company and have some problems to run and configure Android Studio. The network uses a proxy (from Zscaler) and I can't synchronize project from Gradle scripts.
The administrator have given to me the proxy address and on check connection settings, connection is successful with the 2 download domains from the build.gradle
scripts. But it doesn't work on Gradle sync.
THE FOLLOWING ERRORS:
With normal case on build.gradle
:
- Could not GET: "https://dl.google.com.dl/android/maven2/"
- Could not GET: "https://jcenter.bintray.com/
With http on maven blocks: Could not GET (From jcenter binary with http)
Unable to find valid certification path.
I have also import manually certificates from the company, but it doesn't work. You can look on images to show you my configuration I have tried, and it doesn't work.
Images links here:
Help me please, it's extremely important. I can't do the objectives otherwise.
Upvotes: 3
Views: 6074
Reputation: 4225
In my case, I'm on Mac with zscaler
proxy using Android studio Electric Eel
.
Step 1: Download Root CA
I had already the certificate installed in my machine so I went in Keychain Access
, then System Roots
, right click on the zscaler cert and exported
in Desktop
.
At this point, depending on how you saved the cert you should have something similar to:
tree ~/Desktop
- Zscaler-Root-CA.cert
Step 2: import cert
As mentioned before:
keytool -import -trustcacert -file ~/Desktop/Zscaler-Root-CA.cert -alias custom-Root-CA -keystore /Application/Android\ Studio.app/Contents/jbr/Contents/Home/lib/security/cacerts
Use password changeit
.
Step 3: close and restart android studio
Without restart it didn't work. After the restart gradle
downloaded automatically and built the app.
Upvotes: 1
Reputation: 71
The official solution, with keytool (3 lines to execute at least):
On command line (cmd, terminal), open the directory /jre/bin, commands to write:
keytool -import -alias <alias> -file <certificate_path .crt or .cer> -keystore ../jre/lib/security/cacerts
Each Java part (JRE) must to have certificates added with keytool (Java, Android Studio,...), the 2 lines must to be executed:
keytool -import -alias <alias> -keystore <path_to>\system\tasks\cacerts -file <certificate_path .crt or .cer>
keytool -importkeystore -srckeystore <path_to>\system\tasks\cacerts -destkeystore "<path_to>\Java\<jre_path_name>\lib\security\cacerts"
Reboot the system after.
I remember the source: http://andreyaleev.com/2018/01/14/setup-proxy-in-android-studio/
Upvotes: 0
Reputation: 555
You need to inject your companies proxy cert into the cacerts keystore of the java attempting to download files. This may be either the OpenJDK version that is supplied with your Android Studio or the one being used by the operating system.
Keytool is located in /jre/bin
The "cacerts" file is located in /jre/lib/security
Run the following
keytool -importcert -file <path to cert> -keystore <path to cacerts>
-alias <anything>
You'll be prompted for the password, default is "changeit"
You'll then be asked if you trust the cert, type yes.
Upvotes: 4