Can't update to Android Studio gradle 1.4 plug

2019-03-15 13:36发布

In my build.gradle I have:

buildscript {
    repositories {
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.4.+'
    }
}

However I'm getting:

Error:Could not find com.android.tools.build:gradle:1.4.+.
Searched in the following locations:
    file:/C:/AndroidStudio/gradle/m2repository/com/android/tools/build/gradle/1.4.1/gradle-1.4.1.pom
    file:/C:/AndroidStudio/gradle/m2repository/com/android/tools/build/gradle/1.4.1/gradle-1.4.1.jar
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/1.4.1/gradle-1.4.1.pom
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/1.4.1/gradle-1.4.1.jar
Required by:
    :xxx:unspecified

What to do?

5条回答
唯我独甜
2楼-- · 2019-03-15 14:01

Huh, I've replaced mavenCentral() with jcenter() and now it finds the plugin.

I wonder if this is a bug in the build system.

查看更多
可以哭但决不认输i
3楼-- · 2019-03-15 14:10

Make sure your Android Studio version (if you are on alpha or beta build) matches the gradle plugin version. For example, on my machine I had to make sure that my Android Studio 2.0 beta 2 matches the plugin via classpath 'com.android.tools.build:gradle:2.0.0-beta2'

查看更多
forever°为你锁心
4楼-- · 2019-03-15 14:11

classpath 'com.android.tools.build:gradle:1.5.0'

works for me

But better to get the last version here

查看更多
可以哭但决不认输i
5楼-- · 2019-03-15 14:12

Add multiDexEnabled true

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "xyz.jgeovani.loginactivity"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true // This instruction is possibitou use classpath '...tools.build:gradle:1.4.+'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

For using gradle 1.4.+

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.4.+'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
查看更多
祖国的老花朵
6楼-- · 2019-03-15 14:21

It happens because the gradle plugin for android 1.4.+ doesn't exist (currently) in central maven.

You can check here the full list of the versions available on Central Maven.

Use the last stable version:

classpath 'com.android.tools.build:gradle:1.3.1'

If you want to use the beta version you have to use jcenter and

buildscript {
    repositories {
        jcenter()    
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.4.0-beta6'
    }
}

Here the jcenter full list.

EDIT 03/11/2015
Also the beta plugin 1.5.x is only on jcenter.

buildscript {
     repositories {
         jcenter()
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:1.5.0-beta1'
     }
}
查看更多
登录 后发表回答