2017-04-08 70 views
0

我是Android應用程序開發新手。我正在嘗試使用TabLayout創建一個Android應用程序,並在build.gradle文件中添加了以下依賴項。Gradle同步失敗:無法找到參數> [目錄'庫']的方法compile()

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support:design:25.3.1' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 
compile 'com.android.support:support-v4:25.3.1' 
testCompile 'junit:junit:4.12' 
} 

但上運行的應用程序,我正在建立自己的錯誤如下

搖籃同步失敗:在類型的對象無法找到論據方法編譯() [目錄「庫」] org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。 更多細節

任何幫助,將不勝感激:)請教IDE日誌

回答

0

更改編譯文件樹編譯文件。這應該工作。

+0

試過這個。它不起作用 –

+0

除了給定的依賴關係外,是否還有任何庫文件包含在項目中? – fightingCoder

+0

不,我只是想使用TabLayout,所以我添加了這個依賴關係。在此之前,我嘗試了一個沒有TabLayout的簡單應用程序。它工作正常 –

0

有2個build.gradle。 - android/build.gradle - android/app/build.gradle

在我的情況下將依賴項移動到2(android/app/build.gradle)工作。

相關問題