New Jack toolchain crashes when using android-apt plugin

╄→гoц情女王★ 提交于 2019-11-30 04:44:35

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.

Guillem Roca

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.

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