Android Studio 3.2 ,Gradle 4.6
在我的build.gradle中:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.BUTTER_KNIFE_VERSION = '8.8.1'
ext.GLIDE_VERSION = '4.2.0'
ext.KOTLIN_VERSION = '1.2.41'
ext.REALM_VERSION = '4.1.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "io.realm:realm-gradle-plugin:$REALM_VERSION"
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 {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
在我的app / build.gradle中:
kapt "com.android.databinding:compiler:3.1.2"
我的Android项目成功构建并运行。 很好。
现在,我升级到最新版本的插件:
buildscript {
ext.BUTTER_KNIFE_VERSION = '8.8.1'
ext.KOTLIN_VERSION = '1.2.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "io.realm:realm-gradle-plugin:$REALM_VERSION"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
}
}
在app / build.gradle中:
kapt "com.android.databinding:compiler:3.1.4"
项目成功构建,但是当我运行项目时出现错误:
:app:kaptGenerateStubsDebugKotlin
e: myproject\app\build\generated\data_binding_base_class_source_out\debug\dataBindingGenBaseClassesDebug\out\com\myproject\databinding\AdvertisingBinding.java:25: error: cannot find symbol
protected AdvertisingBinding(DataBindingComponent _bindingComponent, View _root,
^
symbol: class DataBindingComponent
location: class AdvertisingBinding
我尝试Invalidate cache / Restart
,但无济于事。