13

sdk更新後im無法創建hello world應用程序。 我的build.gradle看起來像這樣找不到com.android.support:support-v4:22.0.0。 SDK更新後

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 22 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     applicationId "com.coders.yo" 
     minSdkVersion 11 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      runProguard false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:22.0.0' 
} 

但構建失敗得到並顯示

Error:A problem occurred configuring project ':app'. 
> Could not resolve all dependencies for configuration ':app:_debugCompile'. 
    > Could not find com.android.support:support-v4:22.0.0. 
    Required by: 
     Yo:app:unspecified > com.android.support:appcompat-v7:22.0.0 

所以我說編譯 'com.android.support:support-v4:22.0.0。'現在我得到

Error:Failed to find: com.android.support:support-v4:22.0.0. 
<a href="openFile">Open File</a><br><a href="open.dependency.in.project.structure">Open in Project Structure dialog</a> 

我已經更新了Android SDK enter image description here 和支持庫 enter image description here

我一直停留在它的過去的幾個小時。可有人請幫我鑑定了問題

回答

12

你的依賴關係的build.gradle似乎是正確的。

嘗試清理緩存(文件 - >無效緩存並重新啓動),然後同步gradle文件並清理並構建。

在你的gradle文件中有一個奇怪的行。 這DSL不會在最後gradle這個插件的存在(您正在使用哪個版本?)

runProguard false 

您應該更新插件(1.1.0),該版本的Gradle(2.2.1),並改變這條線

minifyEnabled false 
+0

現貨!這是確切的問題。我使用的是Android Studio Beta 0.86。已更新且問題得到修復 – playmaker420 2015-04-03 04:44:19

+0

仍然無效:/ – 2015-04-10 19:34:04

+1

嘗試更新Android支持庫/ Repositiry – pvllnspk 2015-05-15 18:54:00

0

因爲我知道這個問題,這是因爲受支持的庫的版本,您需要做什麼,您使用的版本不適用於您當前的配置。

  1. 剛從gradle這個文件
  2. 刪除這條線現在選擇項目轉到模塊設置(按下F12)
  3. 再次添加依賴使用庫的依賴。

使用上述步驟您將添加支持庫的可用版本。

3

so i added compile 'com.android.support:support-v4:22.0.0.' and now i get

Error:Failed to find: com.android.support:support-v4:22.0.0.

如果添加正是,那我覺得你的問題是在年底額外.。 :)

嘗試:

compile 'com.android.support:support-v4:22.0.0' 
compile 'com.android.support:appcompat-v7:22.0.0' 
+1

沒有好運的伴侶。仍然錯誤:無法找到:com.android.support:support-v4:22.0.0 – playmaker420 2015-04-02 18:41:22

+0

你解決了這個問題嗎?我有同樣的問題... – 2015-04-27 16:11:58

0

就我而言,我只需要更新SDK工具和附加功能。

0

如果這可能會幫助某人,經過多次試驗和錯誤,我發現我在build.gradle文件中對應於「library」的目標是錯誤的SDK版本(較舊的版本)。要改變這種情況,你可以手動或者進入模塊設置菜單(右鍵點擊你的項目文件夾 - >打開模塊設置,然後在「庫」 - 屬性中,你可以改變編譯Sdk和構建工具版本。

enter image description here

顯然,這工作對我有所有支持庫和建築工具最新之後。

0

更改gradle版本像我有變化2.1到2.2.1,它是爲我工作。

相關問題