Gradle DSL method not found: 'apt()'

新项目的时候引用了ButterKnife的 apt 插件后,构建报错

Error:(27, 0) Gradle DSL method not found: 'apt()'
Possible causes:<ul><li>The project 'TransactionTest' 
may be using a version of Gradle that does not contain themethod.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>
The build file may be missing a Gradle plugin.<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

解决方法:

Project层的build.gradle

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

module层级的build.gradle

apply plugin: 'android-apt'
android{ 
    ...
}
dependencies { 
    compile 'com.jakewharton:butterknife:8.4.0' 
    apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在当前.gradle文件中添加:apply plugin: 'android-apt' 在根目录的build.gr...
    喜欢丶下雨天阅读 335评论 0 1
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,638评论 25 708
  • 前言 从2013年Google推出Android Studio(后面以AS简称)开始,到现在已经历经3年,版本也发...
    dfqin阅读 1,880评论 1 3
  • 长在十月,山峰比肩每一座丰碑 历史有它的样子,开花和谢落 人民吃着自己的米饭 血液从不曾停止流淌 只有那些倒下的英...
    竹鸿初阅读 230评论 1 2
  • 什么是独立书店,便是独立形态,独立品格,独立操作。简单来说除了经济独立,能够称之为独立书店的,一定要有独特个性、独...
    权大萌阅读 1,640评论 10 34