2016-01-20 42 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')對不對? –