Solved: Gradle DSL method not found: 'apt()'

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):

 

[java] view plain copy View code snippets on CODE Derive to my code slice
  1. apply plugin: 'com.android.application'  
  2. apply plugin: 'android-apt'  

 

[java] view plain copy View code snippets on CODE Derive to my code slice
  1. buildscript {  
  2.     repositories {  
  3.         jcenter ()  
  4.     }  
  5.     dependencies {  
  6.         classpath 'com.android.tools.build:gradle:2.0.0'  
  7.         classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  
  8.   
  9.   
  10.         // NOTE: Do not place your application dependencies here; they belong  
  11.         // in the individual module build.gradle files  
  12.   }  
  13. }  

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326598546&siteId=291194637