我正在尝试添加最新版本的 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/