找不到方法'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;' [英] Unable to find method 'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'

查看:374
本文介绍了找不到方法'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

build.gradle

build.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"
    }
}

app/build.gradle

app/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进程.

Possible causes for this unexpected error include: Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project. In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

推荐答案

我在gradle同步中也遇到了相同的错误,特别是与黄油刀相关的问题,我的解决方案是通过

I had the same error with gradle syncing, specifically tied to butterknife, my solution was solved via

https://github.com/JakeWharton/butterknife/issues/963 #issuecomment-339545297

tldr在您的项目构建文件中...

tldr in your project build file...

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 
   }
 }
}

还要确保您的所有项目都包含

Also make sure your allproject includes

allproject{
  repositories{
    maven {
      //this
      url "https://oss.sonatype.org/content/repositories/snapshots"
    }
   }
 }

然后与黄油刀相关的问题是将我的buildToolsVersions升级到应用构建文件中的"26.0.2"

And then the none butterknife related issue was upping my buildToolsVersions to "26.0.2" in your app build file

更新4/19/2018 此后与黄油刀分开,因为它引起的问题比我使用过的任何其他第三方都要多.此外,在Kotlin的全力支持下,不必使用黄油刀

UPDATE 4/19/2018 Have since parted ways with butterknife as it has since caused more issues than any other 3rd party I've used. Besides, with full Kotlin support, butterknife isn't necessary

这篇关于找不到方法'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆