Aandroid 解决apk打包过程中出现的“Certificate for <jcenter.bintray.com> doesn't match any of the subject alternative names: [*.aktana.com, aktana.com]”的问题

有时候,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搞不定的资源它还能下载。

猜你喜欢

转载自www.cnblogs.com/chy18883701161/p/10991654.html