Gradle DSL方法未找到:'apt()' [英] Gradle DSL method not found: 'apt()'

查看:743
本文介绍了Gradle DSL方法未找到:'apt()'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b


错误:(31,0)我试图添加最新版本的butterknife,并从gradle得到这个错误:未找到Gradle DSL方法:'apt()'可能的
原因:

  • 项目'MyProject'可能使用不包含该方法的
    Gradle版本。 Gradle设置
  • 构建文件
    可能缺少Gradle插件。申请
    Gradle插件

  • 在我的gradle mobile build.gradle 是:

     插件{
    id net.ltgt.aptversion0.6
    }

    apply plugin:'com.android.application'

    android {
    compileSdkVersion 23
    buildToolsVersion23.0.2

    defaultConfig {
    applicationIdcom.mynamspace.myproject
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName1.0
    }
    buildTypes {
    release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard- rules.pro'
    }
    }
    }

    依赖项{
    编译fileTree(dir:'libs',include:['* .jar' ])
    wearApp项目(':wear')
    testCompile'junit:junit:4.12'
    compile'c​​om .jakewharton:butterknife:8.0.0'
    apt'com.jakewharton:butterknife-compiler:8.0.0'
    compile'c​​om.android.support:appcompat-v7:23.3.0'
    compile'c​​om.google.android.gms:play-services:8.4.0'
    compile'c​​om.android.support:design:23.3.0'
    compile'c​​om.android.support:support -v4:23.3.0'
    compile'c​​om.android.support:recyclerview-v7:23.3.0'
    }

    gradle-apt-plugin有什么问题?

    解决方案

    完全有可能让你的插件起作用。考虑到你的错误,我会首先回顾ButterKnife项目的使用情况,开始工作,然后看看是否有你想要的东西。

    首先,在您的顶级 build.gradle 文件,在 buildscript 中包含 classpath'com.neenbedankt.gradle.plugins:android-apt:1.8' 依赖关系,例如:

      buildscript {
    repositories {
    mavenCentral()
    }
    依赖关系{
    classpath'com.android.tools.build:gradle:2.0.0'
    classpath'com.neenbedankt.gradle。 plugins:android-apt:1.8'
    }
    }

    然后,在你的模块的 build.gradle 文件,包含 apply plugin:'com.neenbedankt.android-apt'



    链接来自ButterKnife GitHub仓库的相关文件,来自项目和专用示例应用程序。


    I am trying to add the latest version of butterknife and I get this error from gradle:

    Error:(31, 0) Gradle DSL method not found: 'apt()' Possible causes:

  • The project 'MyProject' may be using a version of Gradle that does not contain the method. Gradle settings
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • Where my gradle mobile build.gradle is:

    plugins {
        id "net.ltgt.apt" version "0.6"
    }
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "com.mynamspace.myproject"
            minSdkVersion 19
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        wearApp project(':wear')
        testCompile 'junit:junit:4.12'
        compile 'com.jakewharton:butterknife:8.0.0'
        apt 'com.jakewharton:butterknife-compiler:8.0.0'
        compile 'com.android.support:appcompat-v7:23.3.0'
        compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.android.support:design:23.3.0'
        compile 'com.android.support:support-v4:23.3.0'
        compile 'com.android.support:recyclerview-v7:23.3.0'
    }
    

    What's wrong with the gradle-apt-plugin?

    解决方案

    It's entirely possible that there's a way to get your plugins to work. Given your error, I'd start by following what the ButterKnife project uses, get that working, then see if there is a recipe for what you're trying.

    First, in your top-level build.gradle file, include classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' in the buildscript dependencies, such as:

      buildscript {
        repositories {
          mavenCentral()
        }
        dependencies {
          classpath 'com.android.tools.build:gradle:2.0.0'
          classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        }
      }
    

    Then, in your module's build.gradle file, include apply plugin: 'com.neenbedankt.android-apt' towards the top.

    The links are to the relevant files from the ButterKnife GitHub repo, from the project and the dedicated sample app.

    这篇关于Gradle DSL方法未找到:'apt()'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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