Have you tried working with macOS’s built-in java_home
path (/usr/libexec/java_home
)?
Lately, I've run into issues where Android Studio overrides the JAVA version, which causes problems — especially with tools like keytool
. I’d like to understand how you’re setting JAVA at that point. Could you share the exact command you're using?
Also, can you confirm the outputs of the following commands — are they consistent or different?
echo $JAVA_HOME
whereis java
which java
echo $PATH
If everything looks correct so far, try checking whether keytool
is accessible like java
or adb
. If it’s not found, it might mean the system isn't detecting keytool
.
In that case, try using the full path:
"$JAVA_HOME/bin/keytool"
This helped me resolve the issue and correctly update the cacerts
. Let me know if that works for you.
sudo "$JAVA_HOME/bin/keytool" -import -trustcacerts \
-alias <Your alias> \
-file <your CRT file> \
-keystore "$JAVA_HOME/lib/security/cacerts" \
-storepass changeit
I'm also surprised that the usual straight forward approach isn’t working. I went through this same setup last year, and everything worked without any extra effort.