2016-12-02 142 views
1

這是我的「應用」代碼看起來象改變它10次後:gradle這個如何解決依賴

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.0" 
    defaultConfig { 
     applicationId "com.adir.cool" 
     minSdkVersion 15 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude module: 'support-annotations' 
     exclude module: 'support-v4' 
     exclude module: 'support-v13' 
     exclude module: 'recyclerview-v7' 
     exclude module: 'design' 
     module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:24.0.0' 
    compile 'com.android.support:design:24.0.0' 
    compile 'com.google.firebase:firebase-appindexing:10.0.0' 
} 

仍不wotking和給我的錯誤..這裏的代碼應該怎麼看?我更新了一切到最新版本。

錯誤:

Error:(30, 0) Cause: startup failed: 
build file 'C:\Users\Adir\AndroidStudioProjects\cool\app\build.gradle': 30: Statement labels may not be used in build scripts. 
In case you tried to configure a property named 'module', replace ':' with '=' or ' ', otherwise it will not have the desired effect. 
@ line 30, column 17. 
      module: 'support-annotations' 
       ^

1 error 

<a href="openFile:C:\Users\Adir\AndroidStudioProjects\cool\app\build.gradle">Open File</a> 

的的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.2' 

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

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 
+0

後你有 – Manza

+0

錯誤@曼扎補充說。並嘗試從下面的用戶的代碼後得到3個新錯誤 – adir

回答

0

如果錯誤是:

Error:Cause: startup failed: 
build file 'C:\Users\Robert\AndroidStudioProjects\MyApplication\app\build.gradle': 30: Statement labels may not be used in build scripts. 
In case you tried to configure a property named 'module', replace ':' with '=' or ' ', otherwise it will not have the desired effect. 
@ line 30, column 17. 
      module: 'support-annotations' 
       ^

1 error 

然後,你需要的一切是要修改的support-annotations排除,因爲這線缺字exclude

這裏是全依賴關係:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude module: 'support-annotations' 
     exclude module: 'support-v4' 
     exclude module: 'support-v13' 
     exclude module: 'recyclerview-v7' 
     exclude module: 'design' 
     exclude module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:24.0.0' 
    compile 'com.android.support:design:24.0.0' 
    compile 'com.google.firebase:firebase-appindexing:10.0.0' 
} 
+0

給我新的錯誤:錯誤:(23,24)未能解決:com.android.support.test.espresso:espresso核心:2.2.2 錯誤: (31,13)無法解析:com.android.support:appcompat-v7:24.0.0 錯誤:(32,13)無法解析:com.android.support:design:24.0.0 錯誤:無法解析解決方案:com.android.support:support-v4:24.0.0 – adir

+0

也發佈主'build.gradle'。你有沒有下載SDK 24? –

+0

哪裏可以找到build.gradle?每次我搜索sdk下載,只需要我到android studio下載。我更新了一切,之前我重新安裝了android studio。 – adir

1

exclude module: 'support-annotations'

2.按照說明添加支持庫: https://developer.android.com/topic/libraries/support-library/setup.html

+0

如何知道我需要添加哪些支持庫?我安裝了所有我已經在sdk管理器中的包 – adir

+0

我不明白這個問題,安裝一個你需要的應用程序;) – Manza

+0

打開一個新項目,仍然有2個錯誤:Error:Failed to resolve:com.android .support:appcompat-v7:25. + 錯誤:未能解決:com.android.support.test.espresso:espresso-core:2.2.2 – adir