Mac 10.9 版本下使用Gradle 编译 Android 项目,报告错误
1 |
Failure initializing default system SSL context |
使用 -debug 参数,得到的详细输出如下
1 2 3 4 5 6 7 8 9 |
2:34:15.273 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50) 22:34:15.278 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32) 22:34:15.279 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:26) 22:34:15.281 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.FileNotFoundException: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/security/cacerts (No such file or directory) 22:34:15.284 [ERROR] [org.gradle.BuildExceptionReporter] at java.io.FileInputStream.open(Native Method) 22:34:15.285 [ERROR] [org.gradle.BuildExceptionReporter] at java.io.FileInputStream.<init>(FileInputStream.java:106) 22:34:15.286 [ERROR] [org.gradle.BuildExceptionReporter] at org.apache.http.conn.ssl.SSLSocketFactory.createSystemSSLContext(SSLSocketFactory.java:299) 22:34:15.288 [ERROR] [org.gradle.BuildExceptionReporter] at org.apache.http.conn.ssl.SSLSocketFactory.createSystemSSLContext(SSLSocketFactory.java:366) 22:34:15.289 [ERROR] [org.gradle.BuildExceptionReporter] ... 147 more |
可以看到,异常信息为
1 |
22:34:15.281 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.FileNotFoundException: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/security/cacerts (No such file or directory) |
到具体的目录下面去看,这个文件果然是不存在的,有些版本链接到了一个不存在的目录,这种情况一般是经历过系统升级,往往会造成这个现象,另外,就是系统安装的Java 是Apple 提供的 Java 版本,而不是 Orcale 官网下载的独立版本。
解决方法是可以到Orcale 官网下载最新版本的 Java ,安装替换即可解决问题。