[Android Studio导入GreenDao后无法解析DaoMaster

问题描述 投票:0回答:1

下面是项目build.gradle和应用程序build.gradle文件

//project build.gradle
buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
    }
}

    //app build.gradle
    apply plugin: 'org.greenrobot.greendao' // apply plugin
    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.flover.greendaodemo"
            minSdkVersion 21
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha5'
        testImplementation 'junit:junit:4.13-beta-3'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.android.support:recyclerview-v7:28.0.0'

        implementation 'org.greenrobot:greendao:3.2.2'
    }

[使用DaoMaster.DevOpenHelper帮助程序时=新的DaoMaster.DevOpenHelper(此,“ notes-db”,null),显示错误,无法解析DaoMaster。怎么了?

android greendao
1个回答
0
投票

我参加聚会有点晚,但是您需要至少有一个@Entity类,GreenDao才能生成类似DaoMaster和DaoSession的类。

因此,只需创建一个用@Entity和所需属性注释的类,然后单击Build->在AndroidStudio中进行构建或Build->在IntelliJ中进行清洁构建。您也可以单击AndroidStudio或IntelliJ右侧的Gradle选项卡,查找GreenDao Gradle任务并运行它。

© www.soinside.com 2019 - 2024. All rights reserved.