构建.gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath 'com.google.gms:google-services:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
应用程序/build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.7.0'
}
}
android{
compileSdkVersion = 26
buildToolsVersion = "26.0.2"
defaultConfig {
minSdkVersion = 16
targetSdkVersion = 26
}
...
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "newApkName.apk"
}
}
}
如何解决问题:
Unable to find method 'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'.
导致此意外错误的可能原因包括:
Gradle 的依赖项缓存可能已损坏(有时会在网络连接超时后发生。)重新下载依赖项并同步
项目(需要网络)
Gradle 构建进程(守护进程)的状态可能已损坏。停止所有 Gradle 守护进程可能会解决此问题。停止 Gradle 构建
进程(需要重新启动)
您的项目可能使用了第三方插件,该插件与项目中的其他插件或版本不兼容
项目要求的 Gradle。
如果 Gradle 进程损坏,您还可以尝试关闭 IDE,然后终止所有 Java 进程。
我在 gradle 同步时遇到了同样的错误,特别是与 Butterknife 相关,我的解决方案是通过解决的
https://github.com/JakeWharton/butterknife/issues/963#issuecomment-339545297
tldr 在您的项目构建文件中...
buildscript{
repositories {
//other repos will likely exist here like jcenter and mavenCentral
//add this closure
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.7.0'
classpath 'com.android.tools.build:gradle:3.0.0'
//change your version to 9.0.0-SNAPSHOT
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
//.. other project level dependencies
}
}
}
还要确保您的 allproject 包括
allproject{
repositories{
maven {
//this
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
}
然后与黄油刀无关的问题提高了我的buildToolsVersions
to "26.0.2"
在您的应用程序构建文件中
更新 2018 年 4 月 19 日
从那时起我就与 Butterknife 分道扬镳了,因为它造成的问题比我使用过的任何其他第三方都多。此外,有了 Kotlin 的全面支持,就不再需要 Butterknife
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)