A problem was found with the configuration of task ‘:mylibrary:extractDebugAnnotations‘ (type ‘Extra

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':mylibrary:extractDebugAnnotations' (type 'ExtractAnnotations').
  - Gradle detected a problem with the following location: 'E:\xxx\Test2\mylibrary\src\main\java'.
    
    Reason: Task ':mylibrary:extractDebugAnnotations' uses this output of task ':mylibrary:greendao' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':mylibrary:greendao' as an input of ':dblibrary:extractDebugAnnotations'.
      2. Declare an explicit dependency on ':mylibrary:greendao' from ':dblibrary:extractDebugAnnotations' using Task#dependsOn.
      3. Declare an explicit dependency on ':mylibrary:greendao' from ':mylibrary:extractDebugAnnotations' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.7/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Android Studio Koala | 2024.1.1

gradle插件版本  8.5.0

gradle版本8.7

在最新版的AndroidStudio和gradle上面使用greenDao,按照之前的配置,会产生上面的错误。

在project的build.gradle里面引入greenDao的插件

dependencies {
        classpath 'com.android.tools.build:gradle:8.5.0'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.3.1' // add plugin

    }

注意在gradle8.0以上要引入greenDao插件版本为3.3.1,greenDao版本用3.3.0,在主module   app的build.gradle下导入

apply plugin: 'org.greenrobot.greendao'
android {
    ...

    greendao {
        schemaVersion 1
        targetGenDir 'src/main/java'
        //生成DaoMaster、DaoSession、Dao包名的目录
        daoPackage 'com.android.sdlc.mylibrary.gen'
    }
}

dependencies {
    //greenDao数据库
    implementation 'org.greenrobot:greendao:3.3.0'
    ...
}

导入完成之后写一个类

然后Build -> make project    会自动生成DaoMaster、DaoSession、Dao文件,然后就就可以使用了,按照以前的用法这样是没问题的。

在最新版本下的主module里引入greenDao这样写也没问题

重点出问题的地方来了

在最新版AndroidStudio和最新版gradle 8.7  下,如果在project里面创建子module,在子module里使用greenDao的话,如果按照上面的写法就会出现最上面的那个问题。

既然出问题了就要解决,直接上处理方法:

重点重点重点,重要的事情说三遍

 只需将targetGenDir这一行配置去掉就可以了,其他都不变。去掉这一行配置之后make project之后你会发现在找不到自动生成的DaoMaster、DaoSession、Dao 这些文件,没关系,这些都是自动生成的不可编辑的文件,实际是已经生成了,可以直接使用,只是没有像之前那样直接显示出来而已,具体为什么变成这样了,需要查询官方资料了解。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时代新人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值