微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Aandroid 解决apk打包过程中出现的“Certificate for <jcenter.bintray.com> doesn't match any of the su

 

有时候,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文件均不行。

 

 

有2种解决方式:

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

原来的build.gradle文件

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

 

修改过后的build.gradle文件

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

 

重新编译一遍,ok。

 

神秘代码

maven{ url 'http://maven.aliyun.com/nexus/content/repositories/central/'}

 

 

 

 

 

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

麻烦,容易出错,不推荐。

 

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

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐