当前位置:网站首页>【greenDao】Cannot access ‘org.greenrobot.greendao.AbstractDaoSession‘ which is a supertype of

【greenDao】Cannot access ‘org.greenrobot.greendao.AbstractDaoSession‘ which is a supertype of

2022-08-10 18:39:00 guangdeshishe

问题

Cannot access ‘org.greenrobot.greendao.AbstractDaoSession’ which is a supertype of ‘com.xxx.greendao.entity.DaoSession’. Check your module classpath for missing or conflicting dependencies

分析

根据提示,意思是说找不到“DaoSession”的父类“AbstractDaoSession”,而AbstractDaoSession是在’org.greenrobot:greendao:3.3.0’库中,但是依赖的BaseModule中明明有引入implement 'org.greenrobot:greendao:3.3.0',这里涉及到引入依赖库implementapi的区别:

  • implement 'org.greenrobot:greendao:3.3.0':只有当前Module可引用到里面的类
    • 假如greenDao是接入到BaseModule中,而AppModule引用BaseModule,这个时候使用implement引入greenDao则在AppModule中是找不到greenDao库中相关类的
  • api 'org.greenrobot:greendao:3.3.0':当前Module和引用了当前Module的Modul都可以使用相关类

解决办法

  1. 将BaseModule中的implement 'org.greenrobot:greendao:3.3.0'改成api 'org.greenrobot:greendao:3.3.0'
  2. 在AppModule中引用BaseModule模块时,也要使用api(project(":base"))替换implementation(project(":base"))
原网站

版权声明
本文为[guangdeshishe]所创,转载请带上原文链接,感谢
https://blog.csdn.net/guangdeshishe/article/details/126258925