Build Error: `Failed to resolve: leakcanary-android` after updating to Gradle 4.4
Build Error: `Failed to resolve: leakcanary-android` after updating to Gradle 4.4
Failed to resolve: leakcanary-android
升级到 Grade 到 4.4 后出现此构建错误。
我启动了一个全新的 Android Studio 项目,但遇到了同样的错误。还有其他人遇到同样的问题吗?
我正在使用 Android Studio 3.1。以下是我全新项目的代码。
build.gradle
应用插件:'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.xi_zz.myapplication"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
}
build.gradle(顶级)
构建脚本{
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properites
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
我添加到这个新项目的唯一代码是下面的代码,在 https://github.com/square/leakcanary 中有说明。
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
这是 leakcanary 中的错误吗?
不太确定。这可能是 Gradle 4.4 的问题,因为我在更新到 Gradle 4.5 后解决了它。
问题是空格
试试这个
调试实现'com.squareup.leakcanary:leakcanary-android:1.5.4'
发布实施'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
Failed to resolve: leakcanary-android
升级到 Grade 到 4.4 后出现此构建错误。
我启动了一个全新的 Android Studio 项目,但遇到了同样的错误。还有其他人遇到同样的问题吗?
我正在使用 Android Studio 3.1。以下是我全新项目的代码。
build.gradle 应用插件:'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.xi_zz.myapplication"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
}
build.gradle(顶级) 构建脚本{
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properites
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
我添加到这个新项目的唯一代码是下面的代码,在 https://github.com/square/leakcanary 中有说明。
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
这是 leakcanary 中的错误吗?
不太确定。这可能是 Gradle 4.4 的问题,因为我在更新到 Gradle 4.5 后解决了它。
问题是空格
试试这个
调试实现'com.squareup.leakcanary:leakcanary-android:1.5.4' 发布实施'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'