我正在尝试GoogleSample的简单数据绑定中的this示例。我可以清楚地编译并安装到我的设备上。活动打开时,将引发以下错误:
12-09 01:05:34.268 1426-1426/? E/EM FG ALGO Iface:: Failed to get File Descriptor
12-09 01:05:34.670 1408-1408/com.orhan.googlecodelabsdatabinding E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.orhan.googlecodelabsdatabinding, PID: 1408
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/KotlinPackage;
at com.orhan.googlecodelabsdatabinding.util.BindingAdapters.getAssociatedColor(BindingAdapters.kt:56)
at com.orhan.googlecodelabsdatabinding.util.BindingAdapters.popularityIcon(BindingAdapters.kt:23)
at com.orhan.googlecodelabsdatabinding.databinding.ActivityMainBindingImpl.executeBindings(ActivityMainBindingImpl.java:193)
at android.databinding.ViewDataBinding.executeBindingsInternal(ViewDataBinding.java:437)
at android.databinding.ViewDataBinding.executePendingBindings(ViewDataBinding.java:409)
at android.databinding.ViewDataBinding$7.run(ViewDataBinding.java:194)
at android.databinding.ViewDataBinding$6.onViewAttachedToWindow(ViewDataBinding.java:162)
at android.view.View.dispatchAttachedToWindow(View.java:13536)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2688)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2695)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1299)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
我的应用程序等级是:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.orhan.googlecodelabsdatabinding"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "android.arch.lifecycle:extensions:1.1.1"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
我的kotlin版本是1.3.11,而Java版本是1.8。