相关文章推荐
睿智的墨镜  ·  Element-Plus ...·  8 月前    · 
谦虚好学的大脸猫  ·  javascript - 一个 ...·  1 年前    · 
傻傻的荒野  ·  SpringBoot整合c3p0、Druid ...·  1 年前    · 
睿智的小蝌蚪  ·  element ui --- table ...·  1 年前    · 
  • Android Studio 编译报错: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath : class X, unresolved supertypes: Y
  • 重启且清除Android Studio缓存没用,clean后重新build也没用。

2、出现这个问题的原因

咱翻译一下Android Studio 的这个报错信息: 下列类的父类找不到,请确保添加了必要的依赖:类X,未找到的父类Y。

为什么找不到类X的父类Y呢?下面举例说明,参考下图:

  • 假设现在有3个module,module A、module B 和 moduleC。
  • 你在module B里定义了类X,在moduleC里定义了类Y,类X的父类是Y,所以你在module B的build.gradle里写上了implementation “moduleC”,这样module B就依赖上了moduleC。
  • 你在module A里想使用类X,所以你在module A的build.gradle里写上了implementation “module B”,这样module A就依赖上了moduleB
  • 现在编译报错了,在module A中,找不到类X的父类Y

下面说说implementation 和 api的区别:

  • 让 A 依赖 B (implementation、api 都可以)
  • 若B implementation C,A 不能调用 C 的方法
  • 若 B api C,A 可以调用 C 的方法(同 compile)

所以,虽然你让module A implementation “module B”,module B implementation “moduleC”,
A中能找到定义在B中的类X,但你在A里无法调用定义在C中的类Y的方法,所以报错了
在这里插入图片描述

3、解决办法

方法一、把module B的build.gradle中的implementation “moduleC” 改成 api “moduleC”
方法二、在module A中implementation “module C”

以上两种方法都能使module A能调用到module C中的方法。这样就能找到定义在module C中的类Y了。

supertypes of the following classes cannot be resolved. make sure you have the required dependencies 目录1、问题2、出现这个问题的原因3、解决办法       1、问题Android Studio 编译报错: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath : class X, unresolved supertypes: Y重启且清除Android Stu
:app:compileDebug Kotlin Super types of the following class es cannot be resolved . Please make su re you
Android studio 编译报错: Super types of the following class es cannot be resolved . Please make su re you have the required dependence Android studio 版本: 具体操作: 1、新增一个module,将Java-WebSocket 导入moudle( implementation "org.java-websocket:Java-WebSocket...
kotlin Android 集成greendao 初始化报错: Super types of the following class es cannot be resolved . Please make su re you have the required dependencies in the class path: kotlin 代码 查了一些资料,说是 kotlin 不支持greendao...
今天用 android studio 新建了个项目,当展示xml文件的时候,提示The following class es could not be instantiated: android . su pport.v7.widget.ActionBarOverLayLayout。 在stackoverflow查了查,解决方案如图所示:
kotlin 项目中引入GreenDao数据库,在编译并运行时出现如下问题: Super types of the following class es cannot be resolved . Please make su re you have the required dependencies in the class path: class org.greenrobot.greendao.t... Android Studio报错:The binary version of its metadata is 1.5.1, expected version is 1.1.15. 26601
Android Studio报错:The binary version of its metadata is 1.5.1, expected version is 1.1.15. 感谢感谢,终于解决了 win10连不上网,“网络重置”后,网络适配器出现感叹号,右下角WLAN消失,网络连接是空白。 ErkeChen: 真是神了 表情包 表情包 表情包 昨天还花了200去维修店检测电脑也没查出来毛病出在哪,今天在家用网上的各种方法试,没抱希望,居然好了 表情包 表情包 表情包 win10连不上网,“网络重置”后,网络适配器出现感叹号,右下角WLAN消失,网络连接是空白。 1 Aug: 当你坠落悬崖, 抓住了一根稻草, 稻草也连根拔掉了 Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac‘ Could not resolve all 【python】获取当前路径下的 以及 子路径下的所有文件