mFeinstein mFeinstein - 1 year ago 209
Android Question

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
  • The project 'MyProject' may be using a version of
    Gradle that does not contain the method. Gradle settings
  • The build file
    may be missing a Gradle plugin. Apply
    Gradle plugin

  • Where my gradle

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

    apply plugin: ''

    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'), ''

    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 ''
    compile ''
    compile ''
    compile ''
    compile ''

    What's wrong with the gradle-apt-plugin?

    Answer Source

    It's entirely possible that there's a way to get your plugins to work. Given your error, I'd start by following what the ButterKnife project uses, get that working, then see if there is a recipe for what you're trying.

    First, in your top-level build.gradle file, include classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' in the buildscript dependencies, such as:

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

    Then, in your module's build.gradle file, include apply plugin: '' towards the top.

    The links are to the relevant files from the ButterKnife GitHub repo, from the project and the dedicated sample app.

    Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download