Adroid Studio 2022.3.1 版本配置greendao提示无法找到

使用环境:Adroid Studio 2022.3.1 + jdk17 + gradle 8.1.0

在配置greendao的过程中,在网上寻找各种方法去配置都显示错误:Plugin with id 'org.greenrobot.greendao' not found.
最后参考简书大佬的文章成功解决问题,链接在此:https://www.jianshu.com/p/d84a8ad5fe39

解决办法如下:
1,修改用于配置项目模块的gradle配置文件build.gradle(module)

buildscript {//添加这个buildscript代码块
    dependencies {
        classpath("org.greenrobot:greendao-gradle-plugin:3.3.1")
    }
}
plugins {//这是原本就有的代码块
    id 'com.android.application' version '8.1.0' apply false
}

2,修改用于配置app模块的gradle配置文件build.gradle(app)

plugins {
    id 'com.android.application'
    id 'org.greenrobot.greendao'//添加这句
}


android {...}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'org.greenrobot:greendao:3.3.0'//添加这句
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
greendao {//添加这个模块
    schemaVersion 1
    targetGenDir 'src/main/java'
    daoPackage 'com.xxx.xxx.greendao.dao'//写自己需要生成dao文件的包名
}

之前报错,主要就是id 'org.greenrobot.greendao'这个包无法找到,找不到的原因就是org.greenrobot:greendao-gradle-plugin:3.3.1需要添加到整个项目模块的配置文件build.gradle(module)中,我一直在app配置文件build.gradle(app)中的添加的,所以一直无法找到

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值