经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » Android » 查看文章
Aandroid 解决apk打包过程中出现的“Certificate for <jcenter.bintray.com> doesn't match any of the subject alternative names: [*.aktana.com, aktana.com]”的问题
来源:cnblogs  作者:chenhongyong  时间:2019/6/10 13:20:17  对本文有异议

 

有时候,apk打包过程中会出现“Certificate for <jcenter.bintray.com> doesn't match any of the subject alternative names: [*.aktana.com, aktana.com]”的错误。

 

这是因为本地计算机不能从jcenter.bintray.com上获取编译所需的某些jar包(被墙了)。

 

比如我的错误是:

Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not HEAD 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.2.0/kotlin-stdlib-1.2.0.jar'.

获取不到https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.2.0/kotlin-stdlib-1.2.0.jar这个包。

 

fanqiang、修改host文件均不行。

 

 

有3种解决方式:

1、使用国内的Maven镜像仓库,需要修改build.gradle文件。此处我们使用阿里的镜像仓库。

原来的build.gradle文件:

  1. 1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. 2
  3. 3 buildscript {
  4. 4
  5. 5 repositories {
  6. 6 google()
  7. 7 jcenter()
  8. 8 mavenCentral() //修改此处,用maven{ url 'http://maven.aliyun.com/nexus/content/repositories/central/'}替换掉mavenCentral(),并放在jcenter()之前,保证被先访问到
  9. 9 }
  10. 10 dependencies {
  11. 11 classpath 'com.android.tools.build:gradle:3.2.0'
  12. 12
  13. 13
  14. 14 // NOTE: Do not place your application dependencies here; they belong
  15. 15 // in the individual module build.gradle files
  16. 16 }
  17. 17 }
  18. 18
  19. 19 allprojects {
  20. 20 repositories {
  21. 21 google()
  22. 22 jcenter()
  23. 23 mavenCentral() //此处也要修改
  24. 24 }
  25. 25 }
  26. 26
  27. 27 task clean(type: Delete) {
  28. 28 delete rootProject.buildDir
  29. 29 }

 

修改过后的build.gradle文件:

  1. 1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. 2
  3. 3 buildscript {
  4. 4
  5. 5 repositories {
  6. 6 maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} //必须放在jcenter()之前,否则无效
  7. 7 google()
  8. 8 jcenter()
  9. 9 }
  10. 10 dependencies {
  11. 11 classpath 'com.android.tools.build:gradle:3.2.0'
  12. 12
  13. 13
  14. 14 // NOTE: Do not place your application dependencies here; they belong
  15. 15 // in the individual module build.gradle files
  16. 16 }
  17. 17 }
  18. 18
  19. 19 allprojects {
  20. 20 repositories {
  21. 21 maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
  22. 22 google()
  23. 23 jcenter()
  24. 24 }
  25. 25 }
  26. 26
  27. 27 task clean(type: Delete) {
  28. 28 delete rootProject.buildDir
  29. 29 }

 

 重新编译一遍,会自动下载缺少的jar包,成功。之后就可以顺利打包apk了。

 

此种方式最简单,也最有效,推荐。

 

 

 

 

 

2、手动修改jcenter()的访问地址

  1. 1 // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. 2
  3. 3 buildscript {
  4. 4
  5. 5 repositories {
  6. 6 google()
  7. 7 jcenter(){url 'http://maven.aliyun.com/nexus/content/groups/public/'} //此处使用的是阿里的镜像仓库
  8. 8 //注意:需要删除maven()才有效
  9. 9 }
  10. 10 dependencies {
  11. 11 classpath 'com.android.tools.build:gradle:3.2.0'
  12. 12
  13. 13
  14. 14 // NOTE: Do not place your application dependencies here; they belong
  15. 15 // in the individual module build.gradle files
  16. 16 }
  17. 17 }
  18. 18
  19. 19 allprojects {
  20. 20 repositories {
  21. 21 google()
  22. 22 jcenter(){url 'http://maven.aliyun.com/nexus/content/groups/public/'}
  23. 23
  24. 24 }
  25. 25 }
  26. 26
  27. 27 task clean(type: Delete) {
  28. 28 delete rootProject.buildDir
  29. 29 }

 

已测,有效。

 

 

 

 

3、复制缺少的jar包的地址(报错信息里有),比如我的是https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.2.0/kotlin-stdlib-1.2.0.jar,使用迅雷下载,手动添加依赖。

很麻烦,十分容易出错,及其不推荐。

 

不得不说迅雷还是很强,很多普通vpn搞不定的资源它还能下载。

 

原文链接:http://www.cnblogs.com/chy18883701161/p/10991654.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号