我正在尝试从android studio中的其他模块访问界面,我的项目结构看起来像这样
projectRoot-folder
app-main-module //this is main app which i run
com.mypackage.files
MyClass.java
build.gradle
other-library-module //this is library module which i added
com.package.files
InterfaceFile.java
build.gradle
build.gradle
settings.gradle
我正在为MyClass.java实现接口,并且工作正常,没有编译错误,但是当我按下运行时它会给出以下错误,任何人都可以解释为什么会这样?,任何帮助表示赞赏谢谢。
Error:(5, 32) error: cannot find symbol class InterfaceFile
Error:(10, 52) error: cannot find symbol class InterfaceFile
Error:(11, 5) error: method does not override or implement a method from a supertype
Error:(16, 5) error: method does not override or implement a method from a supertype
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
答案 0 :(得分:0)
您必须在文件设置中添加。格式为:
include ':module2'
project(':module2').projectDir = new File(settingsDir, '../Project 2/Module2')
然后你必须在依赖树中添加你的builde.gradle(Module:app),这一行:
compile project(':module2')
或进入项目结构> app>依赖关系,单击Add,选择3 Module Dependencies并选择您的模块