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
}

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...