[Android] 編譯工程時(shí)maven報(bào)錯

現(xiàn)象

編譯工程時(shí),編譯log中報(bào)出因?yàn)镾SL證書等原因無法下載下面?zhèn)}庫中的依賴:

1. https://jcenter.bintray.com
2. https://dl.google.com
3. https://dl.google.com/dl/android/maven2

導(dǎo)致編譯失敗。
常見的SSL異常有:

> Could not download xxxxxx.jar (xxx.xxx.xxx:xxx:x.x.x)
      > Could not get resource 'https://jcenter.bintray.com/xxx.xxx/xxx/x.x.x/x.x.x-x.x.x.jar'.
         > Could not GET 'https://jcenter.bintray.com/xxx.xxx/xxx/x.x.x/x.x.x-x.x.x.jar'.
            > Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

解決

  1. 找到工程的根build.gradle腳本
  2. 使用以下阿里云maven倉庫代替repositories節(jié)點(diǎn)中原有的maven()、jcenter()、google()
    maven { url'[https://maven.aliyun.com/nexus/content/groups/public/](javascript:void(0);)'}
    maven { url'[https://maven.aliyun.com/repository/public/](javascript:void(0);)' }
    maven { url'[https://maven.aliyun.com/repository/google/](javascript:void(0);)' }
    maven { url'[https://maven.aliyun.com/repository/jcenter/](javascript:void(0);)' }
    maven { url'[https://maven.aliyun.com/repository/central/](javascript:void(0);)' }
    
  3. 重新sync工程
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容