Android Studio 3.0 annotationProcessor [duplicate]

让人想犯罪 __ 提交于 2019-12-02 23:09:38
Emanuel S

First of all, after upgrading there are a few changes to gradle.

Its important to upgrade to the latest gradle version to fix that.

That means that you need to add the proper version for your build gradle which is currently

 dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
 }

the next step is to remove your android-apt which is not longer needed.

its enough to have only apply plugin: 'com.android.application'

Onec you have done that, change your dependencies from

compile to implementation, apt to annotationProcessor and testCompile to androidTestImplementation

If you have done that invalidate your cache and restart which is very important.

Then it should work.

You can find a working gradle file using the latest version at

app build.gradle and project build.gradle

p/s : For many people still use Realm old version,

Please update to latest version since old version still use "android-apt".

you have to add annotationProcessorOptions in app level gradle.

android {    
compileSdkVersion 26    
buildToolsVersion '26.0.2'    
defaultConfig { 
   applicationId "com.your.packagename"  
   minSdkVersion 16
   targetSdkVersion 26
   versionCode 1
   versionName "1.0"
   testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 

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