1. 首先是Unresolved reference: databinding这个东西。
    折腾过程不说了,贴出项目的的build.gradle

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    buildscript {
    ext.kotlin_version = '1.1.51'
    ext.android_plugin_version = '3.0.0'
    repositories {
    jcenter()
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
    }

    allprojects {
    repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    maven { url 'https://dl.google.com/dl/android/maven2/' }
    }
    }

    task clean(type: Delete) {
    delete rootProject.buildDir
    }

    然后在module的build.gradle里加上

    1
    2
    3
    kapt {
    generateStubs = true
    }
  2. 编译之后,发现GlideApp找不到了,怎么都生成不了。难道这也是kotlin的锅?
    好吧,既然java的注解生成不了,那么用kotlin来

    1
    2
    //annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
    kapt 'com.github.bumptech.glide:compiler:4.2.0'

    然后将glidemodule注解的java类改成kotlin类
    按下CTRL+F9 make project
    全部解决。