Gradle DSL method not found: 'apt ()'

I am trying to add the latest version of butterknife and I get this error from gradle:

Error: (31, 0) Gradle DSL method not found: 'apt ()' Possible causes:

The MyProject project may use a version of Gradle that does not contain a method. Gradle Settings Build file may be missing Gradle plugin. Submit Gradle Plugin Expression

Where is my 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' } 

What happened to gradle -apt-plugin?

+43
android gradle butterknife
Apr 26 '16 at 9:31 on
source share
5 answers

It is possible that there is a way to make your plugins work. Given your mistake, I will start by using the ButterKnife project, earn it, and then see if there is a recipe for what you are trying.

First, in the top-level build.gradle include the classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' in the buildscript dependencies , for example:

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

Then, in your build.gradle module file, include the apply plugin: 'com.neenbedankt.android-apt' at the beginning.

The links refer to the corresponding files from the ButterKnife GitHub repository, from the project and a special example application.

+99
Apr 26 '16 at 22:03
source share

apt is out of date, change apt to the new format:

change

 apt 'com.jakewharton:butterknife-compiler:8.5.1' 

to

 annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 

https://bitbucket.org/hvisser/android-apt/wiki/Migration

http://jakewharton.imtqy.com/butterknife/

+16
Mar 24 '17 at 23:59
source share

Instead:

  plugins {id "net.ltgt.apt" version "0.6"} 

to try:

  apply plugin: 'android-apt' 
+5
Jun 17 '16 at 17:35
source share

In my case, it helped: adding to your build.gradle (not the main one, but the project one):

apply plugin: 'com.neenbedankt.android-apt'

and

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' } } 
+1
Sep 09 '16 at 22:10
source share

Add your apt code to the build.gradle application NOT in main build.gradle.

 dependencies { apt group: 'group name here', name: 'artifact name here', version:'version here' } 

Of course you will have to add the following code to your main build.gradle file

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.2' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } 
0
Jul 19 '17 at 1:07 on
source share



All Articles