2016-12-11 4 views
0

Ich verwende Android Studio 2.2.3 und Build-Tools 24.0.2.Fehlende Annotationsverarbeitung in Android Studio

Einige der Bibliotheken, einschließlich Butterknife, verwenden Annotationen in build.gradle für die App, die ich zu kompilieren versuche. Im ersten bekomme ich diesen Fehler:

Gradle Sync fehlgeschlagen: [: butter-Compiler: 8.4.0 com.jakewharton]

Am AS starten Fenster Ich konnte Methode annotationProcessor() für Argumente nicht gefunden Ich habe die Einstellungen bearbeitet und die Anmerkungsverarbeitung aktiviert. Ich habe die Caches gelöscht und Android neu gestartet. Immer noch diesen Fehler zu bekommen.

App Ebene build.gradle:

buildscript { 
    repositories { 
     jcenter() 
     maven { url 'https://maven.fabric.io/public' } 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.3' 
     classpath 'com.github.triplet.gradle:play-publisher:1.1.4' 
     //noinspection GradleDynamicVersion 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     maven { url 'https://maven.fabric.io/public' } 
    } 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = '3.1' 
    distributionUrl = distributionUrl.replace("bin", "all") 
} 

Mod Ebene build.gradle:

apply plugin: 'com.android.application' 
apply from: '../config/quality/quality.gradle' 
apply plugin: 'com.github.triplet.play' 
//TODO uncomment line below after adding fabric api secret and key to fabric.properties 
//apply plugin: 'io.fabric' 

android { 
    compileSdkVersion 24 
    buildToolsVersion '24.0.2' 
    defaultConfig { 
     applicationId 'com.murphysw.rosie' 
     minSdkVersion 16 
     targetSdkVersion 24 
     testInstrumentationRunner "${applicationId}.runner.RxAndroidJUnitRunner" 
     versionCode 1000 
     // Major -> Millions, Minor -> Thousands, Bugfix -> Hundreds. E.g 1.3.72 == 1,003,072 
     versionName '0.1.0' 
    } 
    signingConfigs { 
     // You must set up an environment var before release signing 
     // Run: export APP_KEY={password} 
     // TODO Add your release keystore in /keystore folder 
     release { 
      storeFile file('keystore/release.keystore') 
      keyAlias 'alias' 
      storePassword "$System.env.APP_KEY" 
      keyPassword "$System.env.APP_KEY" 
     } 

     debug { 
      storeFile file('keystore/debug.keystore') 
      keyAlias 'androiddebugkey' 
      storePassword 'android' 
      keyPassword 'android' 
     } 
    } 
    buildTypes { 
     release { 
      signingConfig signingConfigs.release 

      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 

      ext.betaDistributionReleaseNotesFilePath = 
        file('../crashlytics_release_notes.txt').absolutePath 
     } 

     debug { 
      versionNameSuffix " Debug" 
      debuggable true 
     } 
    } 
    sourceSets { 
     def commonTestDir = 'src/commonTest/java' 
     test { 
      java.srcDir commonTestDir 
     } 
     androidTest { 
      java.srcDir commonTestDir 
     } 
    } 
    //Needed because of this https://github.com/square/okio/issues/58 
    lintOptions { 
     warning 'InvalidPackage' 
    } 
    productFlavors { 
    } 
} 

play { 
    serviceAccountEmail = 'your-service-account-email' 
    pk12File = file('key.p12') 
    // By default publishes to Alpha channel 
    track = 'alpha' 
} 

dependencies { 
    final PLAY_SERVICES_VERSION = '9.6.1' 
// final SUPPORT_LIBRARY_VERSION = '25.0.1' 
    final SUPPORT_LIBRARY_VERSION = '24.0.2' 
    final RETROFIT_VERSION = '2.1.0' 
    final DAGGER_VERSION = '2.5' 
    final DEXMAKER_VERSION = '1.4' 
    final HAMCREST_VERSION = '1.3' 
    final ESPRESSO_VERSION = '2.2.1' 
    final RUNNER_VERSION = '0.4' 
    final BUTTERKNIFE_VERSION = '8.4.0' 
    final AUTO_VALUE_VERSION = '1.3' 
    final AUTO_VALUE_GSON_VERSION = '0.4.2' 
    def daggerCompiler = "com.google.dagger:dagger-compiler:$DAGGER_VERSION" 
    def jUnit = "junit:junit:4.12" 
    def mockito = "org.mockito:mockito-core:1.10.19" 
    // App Dependencies 
    compile "com.google.android.gms:play-services-gcm:$PLAY_SERVICES_VERSION" 
    compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION" 
    compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION" 
    compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION" 
    compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION" 
    compile('com.squareup.sqlbrite:sqlbrite:0.8.0') 
    { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    } 
    compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION" 
    compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION" 
    compile "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION" 
    compile 'com.github.bumptech.glide:glide:3.7.0' 
    compile 'io.reactivex:rxandroid:1.2.1' 
    compile 'io.reactivex:rxjava:1.1.6' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile 'com.jakewharton.timber:timber:4.1.2' 
    compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION" annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION" 
    // Replace provided dependency below with official AutoValue once this issue is fixed 

    // https://github.com/google/auto/issues/268 
    provided "com.jakewharton.auto.value:auto-value-annotations:$AUTO_VALUE_VERSION" provided "com.ryanharter.auto.value:auto-value-gson:$AUTO_VALUE_GSON_VERSION" annotationProcessor "com.google.auto.value:auto-value:$AUTO_VALUE_VERSION" annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.4-rc2' 
    annotationProcessor "com.ryanharter.auto.value:auto-value-gson:$AUTO_VALUE_GSON_VERSION" annotationProcessor 'com.squareup:javapoet:1.7.0' 
    // https://github.com/rharter/auto-value-parcel/issues/64 
    compile "com.google.dagger:dagger:$DAGGER_VERSION" provided 'org.glassfish:javax.annotation:10.0-b28' 
    //Required by Dagger2 
    annotationProcessor daggerCompiler testAnnotationProcessor daggerCompiler androidTestAnnotationProcessor daggerCompiler 
    // Instrumentation test dependencies 
    androidTestCompile jUnit 
    androidTestCompile mockito 
    androidTestCompile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION" 
    androidTestCompile("com.android.support.test.espresso:espresso-contrib:$ESPRESSO_VERSION") 
    { 
     exclude group: 'com.android.support', module: 'appcompat' 
     exclude group: 'com.android.support', module: 'support-v4' 
     exclude group: 'com.android.support', module: 'recyclerview-v7' 
    } 
    androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION" 
    androidTestCompile "com.android.support.test:runner:$RUNNER_VERSION" 
    androidTestCompile "com.android.support.test:rules:$RUNNER_VERSION" 
    androidTestCompile "com.crittercism.dexmaker:dexmaker:$DEXMAKER_VERSION" 
    androidTestCompile "com.crittercism.dexmaker:dexmaker-dx:$DEXMAKER_VERSION" 
    androidTestCompile "com.crittercism.dexmaker:dexmaker-mockito:$DEXMAKER_VERSION" 
    // Unit tests dependencies 
    testCompile jUnit testCompile mockito testCompile "org.hamcrest:hamcrest-core:$HAMCREST_VERSION" testCompile "org.hamcrest:hamcrest-library:$HAMCREST_VERSION" testCompile "org.hamcrest:hamcrest-integration:$HAMCREST_VERSION" testCompile 'org.robolectric:robolectric:3.1' 
} 

// Log out test results to console 
tasks.matching {it instanceof Test}.all { 
    testLogging.events = ["failed", "passed", "skipped"] 
} 
+0

Wie lautet die Graplel-Version in build.gradle? Ist es> 2,2? – Bajal

Antwort

1

Die butter Seite fragt diese Zeile enthalten:

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

Haben Sie gehört, dass in deiner App Level Gradle?

+0

Ich verwende ein Vorlagenprojekt von einer Firma namens Ribot. Es ist weit verbreitet, so dass ich vermute, dass das Problem mit meiner Einrichtung von Android Studio ist. Diese Zeile scheint miteingeschlossen zu sein. AS scheint keinen Annotationsprozessor zu haben. Es sieht so aus, als ob diese Funktion zuvor im Plug-In enthalten war und nun in das System integriert werden soll. Danke! –

+0

Es stellte sich heraus, dass die Ribot-Vorlage ein paar Zeilen fehlte und die build.gradle-Dateien einige zusätzliche Zeilenumbrüche zwischen Aufgaben benötigten. Befolgen Sie die Anweisungen zur Installation von Butterknife hier: https://github.com/JakeWharton/butterknife, um die Annotationsverarbeitung für diese Bibliothek zu aktivieren. –

Verwandte Themen