问题
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?
回答1:
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'
}
}
回答2:
Huh, I've replaced mavenCentral() with jcenter() and now it finds the plugin.
I wonder if this is a bug in the build system.
回答3:
classpath 'com.android.tools.build:gradle:1.5.0'
works for me
But better to get the last version here
回答4:
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'
回答5:
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
}
}
来源:https://stackoverflow.com/questions/32659079/cant-update-to-android-studio-gradle-1-4-plugin