ythy / blog

Give everything a shot
7 stars 0 forks source link

Kotlin with Butterknife #143

Open ythy opened 6 years ago

ythy commented 6 years ago
  1. kotlin-gradle-plugin 版本不能是 1.0.0

    ext.kotlin_version = '1.1.2'
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
  2. Use kapt instead of annotationProcessor(apt) for the compiler dependency.

    
    apply plugin: 'kotlin-kapt'

compile 'com.jakewharton:butterknife:8.4.0' kapt 'com.jakewharton:butterknife-compiler:8.4.0'

ythy commented 5 years ago

注意 Gradle内所有的 apt 都要替换成 kapt 不管相关文件用没用到Kotlin, 否则编译报错

官方:

If you previously used the Android support for annotation processors, replace usages of the annotationProcessor configuration with kapt. If your project contains Java classes, kapt will also take care of them.