Transferred to: http://blog.csdn.net/yanjunhui2011/article/details/52056927
-----------------------------------------------------------------------------------------------
When I built the project today, I found that the apt plugin of ButterKnife was referenced, and my project suddenly reported me such an error. as follows:
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>
After careful observation, I found that the plugin of android-gralde.apt was not referenced in the build.gradle file under my main project.
solution:
In the current .gradle file add:
apply plugin: 'android-apt'
Add a sentence under the dependencies (dependencies) of build.gradle in the root directory:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
The whole code is as follows (don't forget to recompile):
- apply plugin: 'com.android.application'
- apply plugin: 'android-apt'
- buildscript {
- repositories {
- jcenter ()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:2.0.0'
- classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
- }