Gradle 构建工程时jcenter下载慢或超时以及INSTALL_FAILED_OLDER_SDK解决

在使用 Gradle 构建工程时,jcenter 下载慢、超时的解决方法。

方法一:

https 改成 http 协议下载,修改项目根目录下 build.gradle 文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
// jcenter()
jcenter(){url ‘http://jcenter.bintray.com/’}
}
dependencies {
classpath ‘com.android.tools.build:gradle:3.2.1’

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
// jcenter()
jcenter(){url ‘http://jcenter.bintray.com/’}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

方法二:

切换到国内的Maven镜像仓库。如:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
maven{url ‘http://maven.aliyun.com/nexus/content/groups/public/’}
}
dependencies {
classpath ‘com.android.tools.build:gradle:3.2.1’

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
maven{url ‘http://maven.aliyun.com/nexus/content/groups/public/’}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

INSTALL_FAILED_OLDER_SDK原因就是您设备的Android版本过低,app不支持。 在程序的Manifest文件(或build.gradle)中修改minSdkVersion和targetSdkVersion版本号即可。

发表评论

电子邮件地址不会被公开。 必填项已用*标注