问题
I updated Android studio to 3.5 but there is a problem when I use android annotations
Gradle may disable incremental compilation as the following annotation processors are not incremental: jetified-androidannotations-4.6.0.jar (org.androidannotations:androidannotations:4.6.0).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental
I've put android.enableSeparateAnnotationProcessing=true in the gradle.properties file
but it's say that
INFO: The option setting 'android.enableSeparateAnnotationProcessing=true' is experimental and unsupported. The current default is 'false'.
Could not find the AndroidManifest.xml file
回答1:
I had almost the same problem and couldn't build my app after updating android studio and gradle to 3.5 but according to this answer I added this to my defaultConfig{} in app gradle and problem solved!
javaCompileOptions {
annotationProcessorOptions {
arguments = [
"androidManifestFile": "$projectDir/src/main/AndroidManifest.xml".toString()
]
}
}
回答2:
There is 2 way of fixing this issue
Method One - Use Snapshot version
Current Annotation lib version is 4.6, to fix these error temporary you can use a Snapshot version
add the following URL in Project-level Gradle
buildscript {
repositories {
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
}
Method Two - Use javaCompileOptions
Add following code in gradle DSL
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
arguments = ["androidManifestFile": "$projectDir/src/main/AndroidManifest.xml".toString()]
}
}
}
Hope it will work :)
回答3:
AndroidAnnotations does not support Gradle incremental annotation processing, yet. You can still build your app, it only means that incremental compilation time is not as fast as it could be. There is an issue for tracking the implementation of incremental processing.
I suggest not to set android.enableSeparateAnnotationProcessing
flag, as it is experimental, can cause other issues, and will slow down your clean builds.
来源:https://stackoverflow.com/questions/57603476/how-to-fix-android-annotations-4-6-0-compile-with-android-studio-3-5-and-3-5-0-g