2014-10-09 12 views
16

Ich habe mehrere Diskussionen und Blogs über die Kompilierung von Android-Anwendungen in Android Studio mit AndroidAnnotations-Framework speziell this one angeschaut, aber keiner von ihnen hat mir geholfen, loszulegen.Ich kann kein Projekt in AndroidStudio mit AndroidAnnotations-Bibliothek erstellen

Ich benutze Android Studio 0.8.9 und ich zeige auf eine heruntergeladene Gradle 2.1-Binärdatei. Ich benutze Ubuntu 14.04.

Der Gradel Kompilierungsprozess sagt, dass ich eine Kopie von AndroidManifest.xml an einem bestimmten Ort vermisse (bitte sehen Sie die Ausgabe unten), obwohl ich es gefunden habe, wenn ich mit meinem Datei-Explorer in diesen Ordner navigiere.

Bitte beachten Sie auch, dass, um Warnungen zu entfernen, ich

ersetzt
variant.processResources.manifestFile 

von

variant.outputs.processResources.manifestFile 

im gradle Skript.

Hier mein gradle Build-Skript:

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

apply plugin: 'android' 

repositories { 
    mavenCentral() 
} 

configurations { 
    apt 
} 

dependencies { 
    compile fileTree(include: '*.jar', dir: 'libs') 
    compile files('libs/androidsvg-1.2.1.jar') 
    compile 'com.android.support:appcompat-v7:20.0.0' 
    compile 'org.androidannotations:androidannotations-api:3.0' 
    apt 'org.androidannotations:androidannotations:3.0' 
} 

android { 
    compileSdkVersion 20 
    buildToolsVersion "20.0.0" 

    defaultConfig { 
     minSdkVersion 9 
     targetSdkVersion 20 
    } 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the tests to tests/java, tests/res, etc... 
     instrumentTest.setRoot('tests') 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 
    } 
} 

def getSourceSetName(variant) { 
    return new File(variant.dirName).getName(); 
} 

android.applicationVariants.all { variant -> 
    def aptOutputDir = project.file("${project.buildDir}/source/apt/") 
    def aptOutput = new File(aptOutputDir, variant.dirName) 
    println "****************************" 
    println "variant: ${variant.name}" 
    println "manifest: ${variant.outputs.processResources.manifestFile}" 
    println "aptOutput: ${aptOutput}" 
    println "****************************" 

    android.sourceSets[getSourceSetName(variant)].java.srcDirs+= aptOutput.getPath() 

    variant.javaCompile.options.compilerArgs += [ 
      '-processorpath', configurations.apt.getAsPath(), 
      '-AandroidManifestFile=' + variant.outputs.processResources.manifestFile, 
      '-s', aptOutput 
    ] 

    variant.javaCompile.source = variant.javaCompile.source.filter { p -> 
     return !p.getPath().startsWith(aptOutputDir.getPath()) 
    } 

    variant.javaCompile.doFirst { 
     aptOutput.mkdirs() 
    } 
} 

Hier meine Gradle Konsolenausgabe:

Information:Gradle tasks [:compileDebugSources] 
**************************** 
variant: debug 
manifest: [<my_home>/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/debug/AndroidManifest.xml] 
aptOutput: <my_home>/AndroidStudioProjects/ChessPositionManagerAndroid/build/source/apt/debug 
**************************** 
**************************** 
variant: release 
manifest: [<my_home>/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/release/AndroidManifest.xml] 
aptOutput: <my_home>/AndroidStudioProjects/ChessPositionManagerAndroid/build/source/apt/release 
**************************** 
:preBuild 
:preDebugBuild 
:checkDebugManifest 
:preReleaseBuild 
:prepareComAndroidSupportAppcompatV72000Library UP-TO-DATE 
:prepareComAndroidSupportSupportV42000Library UP-TO-DATE 
:prepareDebugDependencies 
:compileDebugAidl UP-TO-DATE 
:compileDebugRenderscript UP-TO-DATE 
:generateDebugBuildConfig UP-TO-DATE 
:generateDebugAssets UP-TO-DATE 
:mergeDebugAssets UP-TO-DATE 
:generateDebugResValues UP-TO-DATE 
:generateDebugResources UP-TO-DATE 
:mergeDebugResources UP-TO-DATE 
:processDebugManifest UP-TO-DATE 
:processDebugResources UP-TO-DATE 
:generateDebugSources UP-TO-DATE 
:compileDebugJava 
Note: Resolve log file to <my_home>/AndroidStudioProjects/ChessPositionManagerAndroid/build/source/apt/androidannotations.log 
Note: 18:29:17.724 [Daemon Thread 16] INFO o.a.AndroidAnnotationProcessor:86 -  Initialize AndroidAnnotationProcessor with options {androidManifestFile=[<my_home>/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/debug/AndroidManifest.xml]} 
Note: 18:29:17.869 [Daemon Thread 16] INFO o.a.AndroidAnnotationProcessor:117 - Start processing for 1 annotations on 8 elements 
Error:18:29:17.885 [Daemon Thread 16] ERROR o.a.h.AndroidManifestFinder:95 - Could not find the AndroidManifest.xml file in specified path : [<my_home>/AndroidStudioProjects/ChessPositionManagerAndroid/build/intermediates/manifests/full/debug/AndroidManifest.xml] 
Note: 18:29:17.886 [Daemon Thread 16] INFO o.a.p.TimeStats:81 - Time measurements: [Whole Processing = 17 ms], [Extract Annotations = 13 ms], [Extract Manifest = 3 ms], 
Note: 18:29:17.887 [Daemon Thread 16] INFO o.a.AndroidAnnotationProcessor:131 - Finish processing 
Note: 18:29:17.954 [Daemon Thread 16] INFO o.a.AndroidAnnotationProcessor:117 - Start processing for 0 annotations on 0 elements 
Note: 18:29:17.954 [Daemon Thread 16] INFO o.a.p.TimeStats:81 - Time measurements: [Whole Processing = 0 ms], 
Note: 18:29:17.955 [Daemon Thread 16] INFO o.a.AndroidAnnotationProcessor:131 - Finish processing 
Warning:Unclosed files for the types '[dummy1412872157721]'; these types will not undergo annotation processing 
1 warning 
Error:Execution failed for task ':compileDebugJava'. 
> Compilation failed; see the compiler error output for details. 
Information:BUILD FAILED 
Information:Total time: 3.981 secs 
Information:2 errors 
Information:1 warning 
Information:See complete output in console 

Ich möchte mich entschuldigen, wenn überhaupt meine Fehler zu offensichtlich ist, aber ich habe gesucht, für einige Stunden, ohne Erfolg.

Antwort

30

Haben Sie versucht, einige Config für apt fügte hinzu:

dependencies { 
     ... 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' 
    } 

    apply plugin: 'android-apt' 

    apt { 
     arguments { 
      androidManifestFile variant.processResources.manifestFile 
      resourcePackageName '<your package>' 
     } 
    } 
+0

ich Ihr habe versucht, gelöst bekommen hinzufügen Vorschlag (Ersetzen mit meinem Paket), aber ich habe den Fehler "Nicht unterstützte Gradle DSL-Methode gefunden: apt()". Und das Hinzufügen von "apply plugin: apt" hat mich in einen anderen Fehler (Plugin nicht gefunden) – loloof64

+1

Ich aktualisierte meine Antwort, stellen Sie sicher, dass Sie Android-Apt als Plugin verwenden – brwngrldev

+0

Mein Skript aktualisiert: Ich habe in den Fehler "Nein solche Eigenschaft: projectDependencies für Klasse: com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated " – loloof64

4

Bewerben Plugin in Ihrem buid.gradle (Modulebene gradle-Datei) wird es

apply plugin: 'android-apt' 
Verwandte Themen