Could not find method apt()

喜欢而已 提交于 2019-12-01 17:36:36

Add

compile 'com.google.dagger:dagger:2.6'
annotationProcessor "com.google.dagger:dagger-compiler:2.6"

inside dependencies

NOTE:

With android gradle plugin 2.2.0 release, the android-apt plugin is no longer needed for annotation processing. The apt function was included in the latest android gradle plugin which called annotationProcessor.

Use annotationProcessor instead of apt

use

compile 'com.google.dagger:dagger:2.19'
annotationProcessor "com.google.dagger:dagger-compiler:2.19"

in your dependencies instead of

 compile 'com.google.dagger:dagger:2.19'
 apt 'com.google.dagger:dagger-compiler:2.19'

You forgot to actually apply android-apt plugin

 apply plugin: 'com.neenbedankt.android-apt'

(but now you should just remove it and use annotationProcessor or kapt with kotlin-kapt depending on your language anyways)

annotationProcessor cannot work if you haven't enabled the option in Android Studio. To do so :

Close your project, click on Configure at the bottom right, then Settings > Build, Execution, Deployment > Compiler > Annotation Processors and tick enable annotation processing.

Then you can use annotationProcessor "com.google.dagger:dagger-compiler:X.X"

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