how to fix Android Annotations 4.6.0 compile with android Studio 3.5 and 3.5.0 gradle

拈花ヽ惹草 提交于 2020-02-04 07:09:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!