微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – 如何从android studio中的另一个模块导入类?

我在单个 android项目中创建了两个模块,命名为x和y.

> Module x有一个类Egg(Package:com.example.x)
>模块y有一个类Foo(Package:com.example.y)

现在我想在类Egg中导入Foo类,为此我在类Egg中写下面提到的语句

Import com.example.y.Foo;

现在,Foo不被android识别.

问题,

Is it possible to import Class from a different module using just
import statement?

Do I need to create library of Module y and then import created
library into module x?

或者解决方案可能是别的.

解决方法

确保以下内容

在settings.gradle中,您应该具有:include’:x’,’:y’.

在x / build.gradle中,应该添加y作为依赖关系:

dependencies {
        compile project(':y')
        // other dependencies
}

原文地址:https://www.jb51.cc/java/122519.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐