Mor*_*ard 5 android gradle java-8 android-annotations android-gradle-plugin
我试图让retrolambda通过与gradle这个Android编译工作.对java 8的更改导致了android注释的一些问题.
我从这些帖子中尝试了几乎所有内容:(在阅读所有这些链接之前更新3)
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
如何使用Google Android Gradle Plugin编译AndroidAnnotations?
但我一直得到这些错误:
Gradle:错误:包android.annotation不存在
Gradle:错误:找不到符号类TargetApi
那些gradle警告:
Gradle ::支持处理器'com.googlecode.androidannotations.AndroidAnnotationProcessor'支持的源版本'RELEASE_6'小于-source'1.8'
Gradle ::任何处理器都无法识别以下选项:'[androidManifestFile]'
这是我的build.gradle文件,使用/sf/answers/1176155151/(链接3最热门的解决方案):
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
]
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Intellij EDEA 13.0.2.
我没有输出android.applicationVariants.all中println语句内容的任何输出 - 我应该在哪里看到它们?
关于如何解决这个问题的任何线索?
更新1:
我已经尝试使用Groovy调试build.gradle并且每个东西都打印得很好.为每个构建类型构建\ source\apt_generated\debug的正确路径.
但我收到一些警告:
不建议按需创建属性(也称为动态属性),并计划在Gradle 2.0中删除它们. 有关替换动态属性的信息,请阅读 http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html.不推荐使用的动态属性:"com.android.build.graternal.api.ApplicationVariantImpl_Decorated@4445b7e3"上的"aptOutput",值:"C:\ projectpath ...".
****************************
variant:debug
manifest:C:\ projectpath\build\manifests\debug\AndroidManifest.xml
aptOutput:C :\ projectpath\build\source\apt_generated\debug
****************************
在多个位置创建的不推荐使用的动态属性"aptOutput".
****************************
variant:release
manifest:C:\ projectpath\build\manifests\release\AndroidManifest.xml
aptOutput:C :\ projectpath\build\source\apt_generated\release
****************************
****************************
变体:testflight
manifest:C:\ projectpath\build\manifests\testflight\AndroidManifest.xml
aptOutput:C:\ projectpath\build\source\apt_generated\testflight
****************************
并且apt_generated\debug文件夹中没有内容.任何线索?
更新2:
我尝试使用Dodges回答,除了警告之外产生相同的输出,但仍然没有apt_generated\debug文件夹中的内容.
更新3:
我发现问题与链接的帖子有关.这是它无法找到的android.annotations - 而不是androidannotations.但仍然没有解决方案..
我已经通过直接包含android-sdk/tools/support/annotations.jar中的annotations.jar文件解决了这个问题.但这有点像黑客.
我仍然在寻找一个真正的解决方案.
| 归档时间: |
|
| 查看次数: |
5266 次 |
| 最近记录: |