我在单个
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 }