GreenDao配置步骤

GreenDao配置步骤

Project下的build.gradle文件加入

buildscript {
    
    repositories {
        google()
        jcenter()
        mavenCentral() // 添加代码仓库  步骤1
        
    }
    dependencies {
         classpath "com.android.tools.build:gradle:4.0.1"
		
		//步骤2
        classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0' //本地Greendao数据库

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

Module下的build.gradle文件加入

apply plugin: 'com.android.application'

apply plugin: 'org.greenrobot.greendao' // apply plugin 步骤3

android {
	
	........
	
	//greendao配置  步骤5
    greendao {
        //数据库版本号,升级时修改
        schemaVersion 1
        //生成的DAO,DaoMaster和DaoSession的包路径。把com.mypro修改为与表实体所在的包路径相同(自己的项目主包路径)
        daoPackage 'com.mypro.db'
        //生成源文件的路径。默认源文件目录是在build目录中的(build/generated/source/greendao)
        targetGenDir 'src/main/java'
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
	
	//greenDAO配置  步骤4
    implementation 'org.greenrobot:greendao:3.2.2' // add library
    implementation 'org.greenrobot:greendao-generator:3.2.2'
	
}

然后通过AndroidStudio build/Make Project 从新编译

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值