最近在编译andrioid源码时遇到了如下奇葩的Error,一脸三角函数懵逼 o_O!!
Exception in thread "main" java.security.ProviderException: Could not initialize NSS
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:223)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:224)
at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:206)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.jca.ProviderConfig.doLoadProvider(ProviderConfig.java:206)
at sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:187)
at sun.security.jca.ProviderList.loadAll(ProviderList.java:282)
at sun.security.jca.ProviderList.removeInvalid(ProviderList.java:299)
at sun.security.jca.Providers.getFullProviderList(Providers.java:173)
at java.security.Security.insertProviderAt(Security.java:360)
at java.security.Security.addProvider(Security.java:407)
at com.android.signapk.SignApk.main(SignApk.java:848)
Caused by: java.io.IOException: NSS initialization failed
at sun.security.pkcs11.Secmod.initialize(Secmod.java:223)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:218)
... 16 more
make[1]: *** [out/target/product/Z018/obj/APPS/framework-res_intermediates/package.apk] 错误 1
make[1]: *** 正在等待未完成的任务....
本来编译是好好的,也不知道怎么手贱给就弄成这样了。。。(估计是用了apt-get upgrade....)
So easy,立马按照常规旅程google呗~
查了一圈后发现悲剧了。。。what! 就没人遇到过么?????
额,没办法。不能重装系统,折腾了几天,终于自己找到了解绝办法~
特意写出来,分享给大家。
我的解决路程如下:
1:重新安装一次Openjdk7,从而避免Openjdk7的NSS配置被我手贱给修改过
(sudo apt-get purge openjdk-7* 删除后再使用 sudo apt-get install openjdk-7-jdk安装一次)
2:删除所有可能和Nss相关的包,删除方式 sudo apt-get purge libnss*
3:使用sudo apt-get autoremove 删除不再需要的依赖库
4:sudo apt-get update更新源
5:
sudo apt-get install libnss3
sudo apt-get install nss-updatedb
sudo apt-get install nss-passwords
sudo apt-get install nsscache
sudo apt-get install libnss3-dbg
sudo apt-get install libnss-db
sudo apt-get install libnss
sudo apt-get install libnss-sss
sudo apt-get install libnss-cache
sudo apt-get install libnss3-dev
sudo apt-get install libnss3
sudo apt-get install libnss3-nssdb
sudo apt-get install libnss3-dev
sudo apt-get install libnss3-1d
sudo apt-get install libnss3-d
安装如上的包
6:配置好java,确保java和javac -version均为openjdk7
okay,再实验,问题完美解决。
希望我的血泪史对大家有所帮助~ 如有任何问题,欢迎交流