greenDaoCannot access ‘org.greenrobot.greendao.AbstractDaoSession‘ which is a supertype of

Posted guangdeshishe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了greenDaoCannot access ‘org.greenrobot.greendao.AbstractDaoSession‘ which is a supertype of相关的知识,希望对你有一定的参考价值。

问题

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"))

以上是关于greenDaoCannot access ‘org.greenrobot.greendao.AbstractDaoSession‘ which is a supertype of的主要内容,如果未能解决你的问题,请参考以下文章

greenDaoCannot access ‘org.greenrobot.greendao.AbstractDaoSession‘ which is a supertype of

SQLSTATE[42000]: Syntax error or access violation

Git - BUGremote: Incorrect username or password (access token)

Git - BUGremote: Incorrect username or password (access token)

Can't get Access Token for Facebook SDK 4.8.1 for Android (OR) FacebookCallback is not called (OR) r

You may experience an access violation when you access an STL object through a pointer or reference