我刚刚将 Android Studio 升级到 1.0RC4。我的一个 Android 项目使用了较旧的 buildToolVersion
,因此 Android Studio 建议我升级到 19.1.0
,但是从 Android Studio 下载时出现以下错误:
Loading SDK information...
Refresh Sources:
Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Fetched Add-ons List successfully
Refresh Sources
Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-10.xml, reason: SSL java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Refresh Sources:
Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-10.xml, reason: SSL java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
There is nothing to install or update.
我在 google 和 SO 上看到了几个相关问题,但没有一个与 Android Studio 相关,也没有适合我的解决方案。
下面是关于我的环境的更多信息
File -> Project Structure
Android SDK Location: /Applications/Android Studio.app/sdk
JDK Location: /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
$ java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
1.8.0_25, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
1.7.0_07, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
1.6.0_35-b10-428, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home
1.6.0_35-b10-428, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
我尝试过的解决方案:
cd $(/usr/libexec/java_home -v 1.7)/jre/lib/security
ln -fsh /System/Library/Java/Support/CoreDeploy.bundle/Contents/Home/lib/security/cacerts
完成上述操作后,我重新启动了 Android Studio,但同样的问题仍然存在。
最佳答案
我有同样的错误,我最终通过执行这些步骤(在 linux 上)解决了它:
您需要找到 java 正在使用的 keystore ,并在其中导入您尝试访问的网站的 base64 证书:
例如在 ubuntu 上,所有 java 证书都在 /etc/ssl/certs/java/cacerts 中,默认密码为“changeit”。
要导入我必须以这种方式使用 keytool 的证书:
keytool -importcert -trustcacerts -alias myalias -file path_to_cert_file -keystore/etc/ssl/certs/java/cacerts
并在询问时使用changeit作为密码;我不知道 Java keystore (通常名为 cacerts)在 OsX 上的位置。当然你还需要导出https://dl-ssl.google.com来自浏览器的证书。
关于java - 下载 Android SDK Build Tools 19.1 时出现 trustAnchors 参数必须为非空错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27327931/