我正在尝试添加最新版本的 butterknife,但我从 gradle 收到此错误:
Error:(31, 0) Gradle DSL method not found: ‘apt()’ 可能原因:
项目“MyProject”可能正在使用不包含该方法的 Gradle 版本。摇篮设置 构建文件可能缺少 Gradle 插件。应用 Gradle 插件
我的 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 有什么问题?
原文由 Michel Feinstein 发布,翻译遵循 CC BY-SA 4.0 许可协议
完全有可能让你的
plugins
工作。鉴于您的错误,我将首先关注 ButterKnife 项目使用的内容,使其正常工作,然后查看是否有您正在尝试的方法。First, in your top-level
build.gradle
file , includeclasspath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
in thebuildscript
dependencies
, such as:然后,在 您模块的
build.gradle
文件 中,将apply plugin: 'com.neenbedankt.android-apt'
到顶部。这些链接指向来自 ButterKnife GitHub 存储库、项目和专用示例应用程序的相关文件。