4

我用google android gradle插件和android注释编译了一个android项目,似乎java在android注释生成一些源文件之前编译源代码。这有什么问题?谢谢!

我编译:

  git clone git@github.com:sinojelly/androidannotations-dagger-example.git -b google-android-gradle-plugin

build.gradle 是:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }  
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4.2'
        classpath 'com.googlecode.androidannotations:androidannotations:2.7.1'
        classpath 'com.googlecode.androidannotations:androidannotations-api:2.7.1'
    }  
}

repositories {
    mavenCentral()
}

apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile 'com.squareup.dagger:dagger-compiler:1.0.1'
    compile 'com.squareup.dagger:dagger:1.0.1'
    compile 'com.squareup:otto:1.3.3'
}

android {
    compileSdkVersion 17 
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 16 
    }  

}


configurations {
    androidannotations
    androidannotations.extendsFrom(compile)
}

dependencies {
    androidannotations 'com.googlecode.androidannotations:androidannotations:2.7.1'
    compile 'com.googlecode.androidannotations:androidannotations-api:2.7.1'
}


android.applicationVariants.each { variant ->
            variant.javaCompile.classpath += configurations.androidannotations
            variant.javaCompile.options.compilerArgs += [
                '-processor', 'com.googlecode.androidannotations.AndroidAnnotationProcessor',
                '-AandroidManifestFile=' + variant.processResources.manifestFile
            ]
}

运行命令:

gradle assemble

收到此错误消息:

19:37:26.692 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: -d /home/jelly/code/test/androidannotations-dagger-example/build/classes/debug -g -bootclasspath /home/jelly/android-sdk/platforms/android-17/android.jar -processor com.googlecode.androidannotations.AndroidAnnotationProcessor -AandroidManifestFile=/home/jelly/code/test/androidannotations-dagger-example/build/manifests/debug/AndroidManifest.xml -classpath /home/jelly/.gradle/caches/artifacts-24/filestore/javax.inject/javax.inject/1/jar/6975da39a7040257bd51d21a231b76c915872d38/javax.inject-1.jar:/home/jelly/.gradle/caches/artifacts-24/filestore/com.squareup/otto/1.3.3/jar/ca71dea7c3da8abbabe07e037b6f1a7c8974982d/otto-1.3.3.jar:/home/jelly/code/test/androidannotations-dagger-example/libs/android-support-v4.jar:/home/jelly/.gradle/caches/artifacts-24/filestore/com.googlecode.androidannotations/androidannotations-api/2.7.1/jar/64169e7aacaaa76f5a0ca5eea66e2fc02737a17/androidannotations-api-2.7.1.jar:/home/jelly/.gradle/caches/artifacts-24/filestore/com.squareup.dagger/dagger/1.0.1/jar/ec469f2b494fed2aec5af606b61e66ab5ac451cd/dagger-1.0.1.jar:/home/jelly/.gradle/caches/artifacts-24/filestore/com.squareup/javawriter/1.0.5/jar/d4576fdb2fb07cd80ab10c0651c5dbf4de28475c/javawriter-1.0.5.jar:/home/jelly/.gradle/caches/artifacts-24/filestore/com.squareup.dagger/dagger-compiler/1.0.1/jar/c879320dc5c3cfd5cd069899a75c2a5bce8375b5/dagger-compiler-1.0.1.jar:/home/jelly/.gradle/caches/artifacts-24/filestore/com.googlecode.androidannotations/androidannotations/2.7.1/jar/64094f6ec988be410f1ac30e33ef80a8e8cf08dd/androidannotations-2.7.1.jar:/home/jelly/.gradle/caches/artifacts-24/filestore/com.sun.codemodel/codemodel/2.4.1/jar/9784eb8a0a6d68e9c5ee8f86c45020123534bfe/codemodel-2.4.1.jar /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/Pump.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/CoffeeApplication.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/Heater.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/PumpModule.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/DripCoffeeModule.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/ElectricHeater.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/CoffeeActivity.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/Thermosiphon.java /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/CoffeeMaker.java /home/jelly/code/test/androidannotations-dagger-example/build/source/r/debug/info/piwai/androidannotations/dagger/example/R.java /home/jelly/code/test/androidannotations-dagger-example/build/source/buildConfig/debug/info/piwai/androidannotations/dagger/example/BuildConfig.java
19:37:26.694 [INFO] [org.gradle.api.internal.tasks.compile.jdk6.Jdk6JavaCompiler] Compiling with JDK Java compiler API.
19:37:27.354 [ERROR] [system.err] /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/DripCoffeeModule.java:9: 找不到符号
19:37:27.355 [ERROR] [system.err] 符号: 类 CoffeeActivity_
19:37:27.356 [ERROR] [system.err] @Module(injects = CoffeeActivity_.class, includes = PumpModule.class)
19:37:27.357 [ERROR] [system.err]                   ^
19:37:27.410 [ERROR] [system.err] 注意:Starting AndroidAnnotations annotation processing
19:37:27.501 [ERROR] [system.err] 注意:AndroidManifest.xml file found: /home/jelly/code/test/androidannotations-dagger-example/build/manifests/debug/AndroidManifest.xml
19:37:27.953 [ERROR] [system.err] 注意:Number of files generated by AndroidAnnotations: 3
19:37:27.957 [ERROR] [system.err] 注意:Generating source file: coffee.CoffeeActivity_
19:37:27.976 [ERROR] [system.err] 注意:Generating source file: coffee.CoffeeApplication_
19:37:27.992 [ERROR] [system.err] 注意:Generating source file: coffee.ElectricHeater_
19:37:27.997 [ERROR] [system.err] 注意:Time measurements: [Whole Processing = 540 ms], [Extract Manifest = 309 ms], [Process Annotations = 77 ms], [Generate Sources = 45 ms], [Extract Annotations = 43 ms], [Validate Annotations = 40 ms], [Find R Classes = 26 ms], 
19:37:28.171 [ERROR] [system.err] 注意:Time measurements: [Whole Processing = 0 ms], 
19:37:28.176 [ERROR] [system.err] 注意:Time measurements: [Whole Processing = 0 ms], 
19:37:28.178 [ERROR] [system.err] 警告:以下选项未被任何处理器识别:"[androidManifestFile]"
19:37:28.301 [ERROR] [system.err] /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/CoffeeApplication.java:21: 无法将 dagger.ObjectGraph 中的 <T>get(java.lang.Class<T>) 应用于 (coffee.DripCoffeeModule)
19:37:28.302 [ERROR] [system.err]       objectGraph = ObjectGraph.get(new DripCoffeeModule(this));
19:37:28.303 [ERROR] [system.err]                                ^
19:37:28.360 [ERROR] [system.err] 1 错误
19:37:28.361 [DEBUG] [org.gradle.logging.internal.DefaultLoggingConfigurer] Finished configuring with level: DEBUG, configurers: [org.gradle.logging.internal.OutputEventRenderer@76f8968f, org.gradle.logging.internal.logback.LogbackLoggingConfigurer@3a64c34e, org.gradle.logging.internal.JavaUtilLoggingConfigurer@2d5253d5]
19:37:28.362 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on task artifact state cache (/home/jelly/code/test/androidannotations-dagger-example/.gradle/1.6/taskArtifacts).
19:37:28.363 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
19:37:28.363 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':compileDebug'
19:37:28.364 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :compileDebug FAILED
19:37:28.380 [ERROR] [org.gradle.BuildExceptionReporter] 
19:37:28.381 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
19:37:28.382 [ERROR] [org.gradle.BuildExceptionReporter] 
19:37:28.383 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
19:37:28.384 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':compileDebug'.
19:37:28.384 [ERROR] [org.gradle.BuildExceptionReporter] > Compilation failed; see the compiler error output for details.
19:37:28.386 [ERROR] [org.gradle.BuildExceptionReporter] 
4

1 回答 1

0

我解决了这个问题。这是因为匕首在新版本中改变了界面。另见: https ://github.com/excilys/androidannotations/issues/631

于 2013-06-18T16:00:26.300 回答