6

使用Android的工作室,我也跟着在https://developer.android.com/tools/support-library/setup.html作爲acurately盡我所能的步驟,但它告訴我下面的錯誤:爲什麼Android支持庫不能在我的項目中使用?

Error:Could not find method compile() for arguments [com.android.support:appcompat-v7:18.0.+] on org.gradle.api.interna[email protected]18899229.

Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager compile error

但我已經安裝了支持庫和庫!因爲我也得到了一個錯誤說compiledependencies塊不屬於,所以我把它改成classpath,並得到了以下,類似的錯誤:

Error:Could not find any version that matches com.android.support:appcompat-v7:18.0.+. Required by: :ExpenseTracker:unspecified

Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager could not find and proof of install

正如你可以在這裏看到,它仍然認爲ASR沒有安裝,但截圖證明,它是。那麼我在這裏做錯了什麼?

+0

嘗試更改v7:18.0。+到v7:20. + – Simas

+0

@ user3249477我做到了。不幸的是,沒有解決它:c – Supuhstar

回答

11

我想你把這些行放在錯誤的文件中。

他們應該走在模塊的build.gradle文件,而不是在項目的一個(此似乎是,從截圖)。

此外,dependencies標籤不應該是其他任何東西的孩子。是這樣的:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 20 
    ... 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile "com.android.support:support-v4:18.0.+" 
    ... 
} 

編輯你看到的評論? :)

// NOTE: Do not place your application dependencies here; they belong 
// in the individual module build.gradle files 
+0

謝謝!另外,是的,我看到了評論,但我認爲這是一個平臺依賴。很好,x3 – Supuhstar

4

我的問題是,讓Android Studio升級到最新版本的Gradle插件後,它已經搞亂了我的模塊的構建文件的依賴部分。它將依賴聲明行連接在一起(除了僅僅是評論的行)。分隔行(將每個依賴聲明放在一行中)解決了這個問題。

相關問題