gpt4 book ai didi

java - 错误: cannot find symbol DaoSession and DaoMaster

转载 作者:行者123 更新时间:2023-12-01 07:46:39 25 4
gpt4 key购买 nike

我在我的应用程序中使用 GreenDao。 Proguard 已启用用于调试构建。

添加数据绑定(bind)支持后,出现以下问题:

/app/src/main/java/com/example/MainApplication.java:29: error: cannot find symbol

private DaoSession mDaoSession;

      ^   

symbol: class DaoSession
location: class Main Application

DaoMaster 也出现同样的问题。

另外,这个问题即将到来:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDebugKotlin'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)

应用程序构建.gradle:

apply plugin: 'kotlin-kapt'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//For green dao
apply plugin: 'org.greenrobot.greendao'

buildscript {
ext.kotlin_version = '1.2.41'
...
}
android {
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
...
}
dataBinding {
enabled = true
}

buildTypes {
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

kapt { generateStubs = true }
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'org.greenrobot:greendao:3.2.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.anko:anko-common:0.8.3'
kapt 'com.android.databinding:compiler:3.1.2'
}

apply plugin: 'kotlin-android-extensions'

项目build.gradle:

buildscript {
ext.kotlin_version = '1.2.41'
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
...

最佳答案

像这样更改你的应用程序 build.gradle:

//For green dao
apply plugin: 'org.greenrobot.greendao'

apply plugin: 'kotlin-kapt'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

greendao 插件移到 kotlin 插件之前。

关于java - 错误: cannot find symbol DaoSession and DaoMaster,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50495141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com