android - Gradle DSL 方法未找到 : 'apt()'

标签 android gradle butterknife

我正在尝试添加最新版本的 butterknife ,但我从 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
  • 我的 gradle mobile build.gradle 在哪里:

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

    gradle-apt-plugin 出了什么问题?

    最佳答案

    完全有可能让您的 plugins 工作。鉴于您的错误,我将首先遵循 ButterKnife 项目使用的内容,使其正常工作,然后查看是否有适合您尝试的方法。

    首先,在 your top-level build.gradle file ,在buildscript dependencies中包含classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8',如:

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

    然后,在 your module's build.gradle file , 在顶部包括 apply plugin: 'com.neenbedankt.android-apt'

    链接指向来自 ButterKnife GitHub 存储库、项目和专用示例应用程序的相关文件。

    关于android - Gradle DSL 方法未找到 : 'apt()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36876158/

    相关文章:

    java - EditText 没有为测验应用程序的满分添加分数

    android - 未能安装以下 Android SDK 包,因为某些许可证未被接受。- 20.1.5948944 NDK(并排)20.1.5948944

    java - 设置每行的 Edittext 背景

    android - Butterknife 将 View 绑定(bind)到不同的源

    android - 使用改造的 api 调用在 android 中不起作用

    java - 在 FOR 循环之前调用时未调用 Settext

    logging - 为什么Apache HttpClient 4.5记录HTTP流量这么差?如何使其冗长?

    android - 确保gradle依赖项在应用包中包含32位和64位库

    java - apache在创建JedisConfig对象时在运行时公共(public)ClassNotFoundException

    android-studio - 集成 Butterknife 后未显示菜单项