Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

Here is a Gradel app Here is a Grade build

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

like image 745
Mohammed Hemaid Avatar asked Aug 22 '19 06:08

Mohammed Hemaid


People also ask

Which Gradle version should I use?

If you've updated your Android Studio to 1.3. 2 version then I would suggest using Build Tools Version 23.0. 0 and compile API 23 Android 6.0. As for Gradle Version - 2.4 or higher up to latest 2.7.

What is Android Gradle plugin?

The Android Gradle plugin (AGP) is the official build system for Android applications. It includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.

How do I find my Gradle version?

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.

Does androidannotations support Gradle incremental annotation processing?

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.

Where are the @nullable and @nonnull annotations injected in Android Studio?

Android Studio inserts the Android @Nullable and @NonNull annotations in detected locations in your code. After running a null analysis, it's good practice to verify the injected annotations.

How do I add an annotation to an Android module?

Android supports a variety of annotations through the Annotations Support Library. You can access the library through the android.support.annotation package. Note: If a module has a dependency on an annotation processor, you must use the `annotationProcessor` dependency configuration to add that dependency.

How to integrate annotation processors with Android Studio?

This plugin allows to enhance the integration of annotation processors to Android Studio. Integrating the plugin involves adding the buildscript declaration with the android-apt dependency, applying the plugin and setting the arguments for the plugin.


2 Answers

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()
            ]
        }
    }
like image 54
Mojtaba Avatar answered Oct 08 '22 23:10

Mojtaba


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 :)

like image 26
rinkesh Avatar answered Oct 08 '22 21:10

rinkesh