2014-01-31 7 views
5

Ich versuche, retrolambda mit Android Build von Gradle zu arbeiten. Die Umstellung auf Java 8 hat einige Probleme mit Android-Annotationen verursacht.Gradle mit Java 8 für retroLambda - Android kann keine Anmerkungen finden TargetApi

Ich habe fast alles von diesen Beiträgen versucht: (Sie Update 3, bevor all diesen Links zu lesen)
http://code.google.com/p/android/issues/detail?id=55764
https://bitbucket.org/hvisser/android-apt
AndroidAnnotations Nothing Generated, Empty Activity
Android studio + Gradle + Android Annotations
How to compile AndroidAnnotations with Google Android Gradle Plugin?

Aber ich halte diesen erros bekommen:

Gradle: error: package android.annotation does not exist

Gradle: error: cannot find symbol class TargetApi

Und diese gradle Warnungen:

Gradle: : Supported source version 'RELEASE_6' from annotation processor 'com.googlecode.androidannotations.AndroidAnnotationProcessor' less than -source '1.8'

Gradle: : The following options were not recognized by any processor: '[androidManifestFile]'


Dies ist meine build.gradle Datei https://stackoverflow.com/a/16802216/860488 (Link 3 meisten upvoted Lösung) mit:

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url 'http://download.crashlytics.com/maven' } 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.7.+' 
     classpath 'com.google.guava:guava:14.0.1' 
     classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+' 
     classpath 'me.tatarka:gradle-retrolambda:1.1.1' 
    } 
} 

repositories { 
    mavenCentral() 
    maven { url 'http://download.crashlytics.com/maven' } 
} 

apply plugin: 'android' 
apply plugin: 'crashlytics' 
apply plugin: 'retrolambda' 

ext.daggerVersion = '1.0.0' 
ext.androidAnnotationsVersion = '2.7.1' 

configurations { 
    apt 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile 'com.google.guava:guava:14.0.1' 
    compile 'com.crashlytics.android:crashlytics:1.+' 
    apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}" 
    compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}" 
    apt "com.squareup.dagger:dagger-compiler:${daggerVersion}" 
    compile "com.squareup.dagger:dagger:${daggerVersion}" 
} 

android { 
    packagingOptions { //Fix: https://stackoverflow.com/a/20675331/860488 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/NOTICE' 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 

    compileSdkVersion 10 
    buildToolsVersion "18.0.1" 

    defaultConfig { 
     minSdkVersion 7 
     targetSdkVersion 10 
     buildConfigField "boolean", "useProductionServices", "true" 
    } 

    buildTypes { 
     testflight.initWith(buildTypes.debug) 
     debug { 
      packageNameSuffix ".debug" 
      buildConfigField "boolean", "useProductionServices", "false" 
     } 

     testflight { 
      packageNameSuffix ".testflight" 
      buildConfigField "boolean", "useProductionServices", "true" 
     } 

     release { 
      buildConfigField "boolean", "useProductionServices", "true" 
     } 
    } 
} 

retrolambda { 
    compile "net.orfjackal.retrolambda:retrolambda:1.1.2" 
    jdk System.getenv("JAVA8_HOME") 
} 

android.applicationVariants.all { variant -> 
    aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}") 
    println "****************************" 
    println "variant: ${variant.name}" 
    println "manifest: ${variant.processResources.manifestFile}" 
    println "aptOutput: ${aptOutput}" 
    println "****************************" 

    variant.javaCompile.doFirst { 
     println "*** compile doFirst ${variant.name}" 
     aptOutput.mkdirs() 
     variant.javaCompile.options.compilerArgs += [ 
       '-processorpath', configurations.apt.getAsPath(), 
       '-AandroidManifestFile=' + variant.processResources.manifestFile, 
       '-s', aptOutput 
     ] 
    } 
} 

Ich benutze IntelliJ EDEA 13.0.2 .
Ich sehe keine Ausgabe mit dem Inhalt der println-Anweisungen in der android.applicationVariants.all - wo soll ich sie sehen?

Irgendwelche Hinweise, wie Sie das beheben können?

Update 1:
Ich habe versucht, die build.gradle mit Groovy Debuggen und alles ist in Ordnung gedruckt. Die richtigen Pfade zum Erstellen von \ source \ apt_generated \ debug für jeden Buildtyp.
Aber ich bin immer einige Warnungen:

Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties. Deprecated dynamic property: "aptOutput" on "com.and[email protected]4445b7e3", value: "C:\projectpath...".
****************************
variant: debug
manifest: C:\projectpath\build\manifests\debug\AndroidManifest.xml
aptOutput: C:\projectpath\build\source\apt_generated\debug
****************************
Deprecated dynamic property "aptOutput" created in multiple locations.
****************************
variant: release
manifest: C:\projectpath\build\manifests\release\AndroidManifest.xml
aptOutput: C:\projectpath\build\source\apt_generated\release
****************************
****************************
variant: testflight
manifest: C:\projectpath\build\manifests\testflight\AndroidManifest.xml
aptOutput: C:\projectpath\build\source\apt_generated\testflight
****************************

Und es gibt keinen Inhalt in dem Ordner apt_generated \ debug. Irgendeine Ahnung?

Update 2:
Ich habe versucht, mit Dodges answer der gleichen Leistung mit Ausnahme der Warnungen erzeugt, aber noch keine Inhalte in dem Ordner apt_generated \ debug.

Update 3:
fand ich heraus, dass das Problem etwas anderes, dass die verlinkten Beiträge im Begriff ist, sind. Es ist die android.annotations, die es nicht finden kann - nicht androidannotations. Aber immer noch keine Lösung ..

Antwort

5

Ich habe es gelöst, indem Sie direkt die Datei annotations.jar von android-sdk/tools/support/annotations.jar. Aber das ist eine Art Hack.
Ich bin immer noch auf der Suche nach einer echten Lösung.

0

fügen Sie diese zu Ihrer Root-Abhängigkeit Classpath ‚me.tatarka: gradle-retrolambda: 3.1.0 '