New Jack toolchain crashes when using android-apt plugin
Asked Answered
P

2

21

I'm trying to build a simple project with the new Jack toolchain. My project relies on android-apt plugin (it uses some annotation processing tool, but build error occures, even before I tried to add this tool). Here is my module build script (I'm using Android Studio 1.3 and gradle plugin 1.3.0):

apply plugin: 'com.android.application'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.6'
    }
}
apply plugin: 'android-apt'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.netimen.ui.demo"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        useJack=true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
}

I get the following ouptup, when I try to sync my project:

Error:Could not find property 'options' on task ':demo:compileDebugJavaWithJack'.

When I try to run gradlew assembleDebug --stacktrace I get the following:

org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':demo'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:49)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: groovy.lang.MissingPropertyException: Could not find property 'options' on task ':demo:compileDebugJavaWithJack'.
        at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
        at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
        at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:97)
        at com.android.build.gradle.tasks.JackTask_Decorated.getProperty(Unknown Source)
        at com.neenbedankt.gradle.androidapt.AndroidAptPlugin.configureVariant(AndroidAptPlugin.groovy:51)
        at com.neenbedankt.gradle.androidapt.AndroidAptPlugin$_apply_closure1_closure3.doCall(AndroidAptPlugin.groovy:25)
        at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:110)
        at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:115)
        at org.gradle.api.DomainObjectCollection$all$1.call(Unknown Source)
        at com.neenbedankt.gradle.androidapt.AndroidAptPlugin$_apply_closure1.doCall(AndroidAptPlugin.groovy:24)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:87)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy11.afterEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
        ... 41 more

When I tried removing android-apt plugin, problem disappeared.

Piteous answered 3/8, 2015 at 14:29 Comment(1)
Feel free to accept the answer when you're ready :)Arrivederci
A
27

Edit: As of the latest Android Gradle plugin (2.2) annotation processing is built in, also supporting jack. I've written down the steps to migrate from android-apt

Old answer:

The Jack compiler task does not support passing options for annotation processing yet, as it is still experimental. The Jack compiler itself does support annotation processing, but this is not exposed in the Gradle plugin yet. When that happens, android-apt will probably be updated to support Jack as well.

Arrivederci answered 3/8, 2015 at 19:18 Comment(5)
With Android N preview, Jack is more public now. You have now some work to do @Arrivederci :)Ticktack
As I understand it, Google is working on it. When I have some time, I'll look at what isn't working currently and will file a bug if there's something missing.Arrivederci
I would say not spend your time. We should check with the next build tools update. It should be soon.Ticktack
Wait, we are in official release of sdk android-24 now. We still cannot use annotations and Dagger?Rellia
There's an official API being added in the latest Android Gradle version. That should be the way going forward, although these releases are currently alpha level quality.Arrivederci
S
10

Since the Android Studio 2.2 Preview release you can use annotation processors with the new Jack compiler.

If you want an annotation processor to be applied at compile time but not to be included in your APK, use the annotationProcessor dependency scope in module-level build.gradle:

dependencies {
    compile 'com.google.dagger:dagger:2.0'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}

You can also apply annotation processors for specific build variants:

debugAnnotationProcessor 'com.google.dagger:dagger-compiler:2.0'

Annotation processing requires Android Gradle Plugin version 2.2.0-alpha1 or higher so you need the update to 2.2 is mandatory. To use the plugin, in project-level build.gradle:

classpath 'com.android.tools.build:gradle:2.2.0-alpha1'

You can find some information in Android Tools Tech Docs or here in more conscise and get up and running form, including some info on popular annotation processing frameworks, such as Dagger 2.

Selfexcited answered 1/7, 2016 at 8:53 Comment(2)
Might be silly, but your dagger version has to match your dagger compiler version. Also, 2.2.0-alph5 is out, here's the link to the build tool releases on bintray bintray.com/android/android-tools/…Edentate
In this case you have to comment those lines in your gradle //apply plugin: 'com.neenbedankt.android-apt' and // apt 'com.google.dagger:dagger-compiler:2.0'Selassie

© 2022 - 2024 — McMap. All rights reserved.