Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

[Question] How to configure androidannotations with Jack? #1853

Description

@optisamit

Hi,
android-apt has become obsolete recently, since Android Gradle plugin 2.2 was released in stable channel.
Could you please update your Getting Started docs to show how to do a setup with Jack?
Thanks.

Activity

  1. WonderCsabo commented on Sep 21, 2016

    @WonderCsabo
    Member

    android-apt is not obsolete, becasuse the Jack toolchain is still experimental and disabled by default.

    However you use it with AA. It is described here how to enable annotation processing with Jack.

  2. optisamit commented on Sep 21, 2016

    @optisamit
    Author

    @WonderCsabo Thanks for your reply, but I still can't do it. Could you help me please?
    I've added Jack, commented out every occurrence of apt and replaced apt dependencies with annotationProcessor. And then, if I try gradle syncing, I get this error:

    Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.

    Could it be a bug on Jack's side?

  3. WonderCsabo commented on Sep 21, 2016

    @WonderCsabo
    Member

    Yes, that error is coming from the Gradle build, AA is not even called at that point.

  4. niusounds commented on Sep 30, 2016

    @niusounds

    In Gradle 2.2, AA works with only these codes:

    dependencies {
        annotationProcessor 'org.androidannotations:androidannotations:4.1.0'
        compile 'org.androidannotations:androidannotations-api:4.1.0'
    }
    

    android-apt and classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+' are not needed.

    https://github.com/excilys/androidannotations/wiki/Building-Project-Gradle needs to be updated.

  5. WonderCsabo commented on Sep 30, 2016

    @WonderCsabo
    Member

    AFAIK the Jack toolchain is still experimental, we will add support and documentation when it will be stable.

  6. solgems commented on Nov 3, 2016

    @solgems

    any updates on this?

    even without using JACK, we can do:

    annotationProcessor "org.androidannotations:androidannotations:4.1.0"
    compile "org.androidannotations:androidannotations-api:4.1.0"
    

    instead of

    apt "org.androidannotations:androidannotations:4.1.0"
    compile "org.androidannotations:androidannotations-api:4.1.0"
    

    but how do we pass the path of the manifest file to the new annotation processor?

    apt {
        arguments {
            androidManifestFile variant.outputs[0]?.processResources?.manifestFile
            resourcePackageName android.defaultConfig.applicationId
        }
    }
    

    from http://tools.android.com/tech-docs/jackandjill we can do something like the following below:
    but how do we handle all the different variants like the trick above (documented by https://bitbucket.org/hvisser/android-apt) ??

    android {
    ...
        defaultConfig {
        ...
            javaCompileOptions { 
                annotationProcessorOptions {
                    className 'com.example.MyProcessor'
    
            // Arguments are optional.
                    arguments = [ foo : 'bar' ]
                }
            }
        }
        ...
    }
    
  7. WonderCsabo commented on Nov 3, 2016

    @WonderCsabo
    Member

    We still not support Jack, as it is experimental and has lots of bugs.

    You cannot add per-variant annotation processing options with the new DSL, i reported this issue to Google a while ago. However, you can have an ugly workaround, as can be seen in the issue description:

    android.applicationVariants.all { variant ->
      variant.variantData.variantConfiguration.javaCompileOptions.annotationProcessorOptions.arguments =
        ['androidManifestFile': variant.outputs[0]?.processResources?.manifestFile?.absolutePath]
    }
  8. solgems commented on Nov 3, 2016

    @solgems

    cool, thanks for highlighting the ticket! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions