2016-01-20 39 views
1

我试图从其他模块访问接口android的工作室,我的项目结构看起来像这样无法访问界面的Android

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. 
+3

您必须将其他模块声明为库,并将其作为库添加到您的应用程序模块 –

+0

@小我已经做过 –

回答

0

你必须在你的文件中添加settings.gradle此行:

include ':module2' 
project(':module2').projectDir = new File(settingsDir, '../Project 2/Module2') 

然后,你必须在你的builde.gradle添加(模块:应用程序)的依赖关系树,这行:

compile project(':module2') 

或进入项目结构>应用程序>相关性,点击添加,选择3只模块依赖,并选择你的模块

+0

我不明白文件的第二个参数可以解释吗? –

+0

哪一个你不明白?添加编译项目(':module2')在你用来添加库的依赖项中(例如:compile'c​​om.android.support:appcompat-v7:23.1.1') –

+0

根据我的问题它应该是 project('other -module')。projectDir = new File(settingsDir,':other-module')对不对? –