2016-04-15 107 views
0

我最近決定學習Android編程,因此我在Ubuntu機器上安裝了Android Studio和Android SDK。問題是,當我建立一個新的項目,它說:Android Studio Gradle項目同步完成,出現錯誤

Gradle Sync completed with some erros 

和日誌是:

/home/moein/apps/android-studio-projects/Testapp/app/build.gradle 
    Error:Error:line (24)Failed to resolve: com.android.support:appcompat-v7:23.+ 
    Error:Error:line (23)Failed to resolve: junit:junit:4.12 

我的build.gradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.example.moein.testapp" 
     minSdkVersion 23 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.0.0' 
} 
+0

你可以發佈你的build.gradle文件嗎? – Sanoop

+0

@Sanoop我更新了我的問題 –

回答

0

你在這個有你build.gradle文件:

compile 'com.android.support:appcompat-v7:23.3.0' 
+0

是的,我確實有這個 –

0

最可能的reaso對於這樣的錯誤,你沒有安裝所有的支持庫。轉到SDK管理器並安裝所有支持存儲庫。欲瞭解更多詳情,你可以訪問這個answer

0

這些都是您可以根據API需求添加到您的build.gradle中的正確版本。請根據您的要求使用它。

API 21:

compile 'com.android.support:appcompat-v7:21.0.1' 

OR

compile 'com.android.support:appcompat-v7:21.0.2' 

OR

compile 'com.android.support:appcompat-v7:21.0.3' 

API 22:

compile 'com.android.support:appcompat-v7:22.0.0' 

API 23:

compile 'com.android.support:appcompat-v7:23.2.0' 
0

嘗試安裝以下突出顯示的項目:

Support Library

0

我找到了答案,這個問題。

我以前每次打開一個新項目都會得到它。

只需粘貼的build.gradle這些行(模塊:APP)

repositories { 
    maven { url 'http://repo1.maven.org/maven2' } 
} 

同步一遍它可能會解決您的問題。