赞
踩
1.Android Studio中gradle版本未升级的情况(避免报错的首选方案)
with groovy
(1).build.gradle配置
- buildscript {
- repositories {
- //ADD START
- maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
- maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
- maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
- maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
- maven { url "https://maven.aliyun.com/repository/google" }
- maven { url "https://maven.aliyun.com/repository/public" }
- maven { url "https://maven.aliyun.com/repository/jcenter" }
- maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
- //ADD END
- google()
- jcenter()
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:3.6.3'
- }
- }
-
- allprojects {
- repositories {
- //ADD START
- maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
- maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
- maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
- maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
- maven { url "https://maven.aliyun.com/repository/google" }
- maven { url "https://maven.aliyun.com/repository/public" }
- maven { url "https://maven.aliyun.com/repository/jcenter" }
- maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
- //ADD END
- google()
- jcenter()
- maven {
- url "https://jitpack.io"
- }
- maven {
- url 'https://maven.google.com/'
- name 'Google'
- }
- maven { url "https://jitpack.io" }
- ......
- mavenCentral()
- }
- }
(2).C:\Users\LENOVO\.gradle\init.gradle配置
- allprojects{
- repositories {
- def MY_ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
- def MY_ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
- all { ArtifactRepository repo ->
- if(repo instanceof MavenArtifactRepository){
- def url = repo.url.toString()
- if (url.startsWith('https://repo1.maven.org/maven2')) {
- project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_REPOSITORY_URL."
- remove repo
- }
- if (url.startsWith('https://jcenter.bintray.com/')) {
- project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL."
- remove repo
- }
- }
- }
- maven {
- url MY_ALIYUN_REPOSITORY_URL
- url MY_ALIYUN_JCENTER_URL
- }
- }
- }
2.Android Studio中gradle版本已升级的情况(gradle升级可能jdk版本也需升级)
with groovy
(1).build.gradle配置
- buildscript {
- repositories {
- //ADD START
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/groups/public/'
- }
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
- }
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/repositories/google'
- }
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/google'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/public'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/jcenter'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/gradle-plugin'
- }
- //ADD END
- google()
- mavenCentral()
- maven { url 'https://maven.google.com' }
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:7.0.0'
- }
- }
-
- allprojects {
- repositories {
- //ADD START
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/groups/public/'
- }
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
- }
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/repositories/google'
- }
- maven {
- allowInsecureProtocol = true
- url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/google'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/public'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/jcenter'
- }
- maven {
- allowInsecureProtocol = true
- url 'https://maven.aliyun.com/repository/gradle-plugin'
- }
- //ADD END
- google()
- mavenCentral()
- maven {
- url "https://jitpack.io"
- }
- maven { url 'https://maven.google.com' }
- jcenter()
- maven { url 'https://dl.google.com/dl/android/maven2' }
- }
- }
-
- task clean(type: Delete) {
- delete rootProject.buildDir
- }
(2).C:\Users\LENOVO\.gradle\init.gradle配置
- allprojects{
- repositories {
- def MY_ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
- def MY_ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
- all { ArtifactRepository repo ->
- if(repo instanceof MavenArtifactRepository){
- def url = repo.url.toString()
- if (url.startsWith('https://repo1.maven.org/maven2')) {
- project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_REPOSITORY_URL."
- remove repo
- }
- if (url.startsWith('https://jcenter.bintray.com/')) {
- project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL."
- remove repo
- }
- }
- }
- maven {
- allowInsecureProtocol = true
- url MY_ALIYUN_REPOSITORY_URL
- url MY_ALIYUN_JCENTER_URL
- }
- }
- }
3.with kotlin
- repositories {
- maven {
- isAllowInsecureProtocol = true
- setUrl("http://maven.aliyun.com/nexus/content/groups/public/")
- }
- maven {
- isAllowInsecureProtocol = true
- setUrl("http://maven.aliyun.com/nexus/content/repositories/jcenter")
- }
- maven {
- isAllowInsecureProtocol = true
- setUrl("http://maven.aliyun.com/nexus/content/repositories/google")
- }
- maven {
- isAllowInsecureProtocol = true
- setUrl("http://maven.aliyun.com/nexus/content/repositories/gradle-plugin")
- }
- maven {
- isAllowInsecureProtocol = true
- setUrl("https://maven.aliyun.com/repository/google")
- }
- maven {
- isAllowInsecureProtocol = true
- setUrl("https://maven.aliyun.com/repository/public")
- }
- maven {
- isAllowInsecureProtocol = true
- setUrl("https://maven.aliyun.com/repository/jcenter")
- }
- maven {
- isAllowInsecureProtocol = true
- setUrl("https://maven.aliyun.com/repository/gradle-plugin")
- }
- }
Android Studio gradle无法编译App的完美解决方法
Android Studio中gradle版本升级报gradle的仓库地址不安全警告
Android Studio中gradle版本是否升级的方案(选其一)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。