gradle如何修复依赖项

时间:2016-12-02 13:22:41

标签: java android xml android-studio

这是我的'app'代码在更改10次后的样子:

$gender

仍然没有wotking并给我错误..这里的代码怎么看?我将所有内容更新到最新版本。

错误:

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'
} 

build.gradle

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>

2 个答案:

答案 0 :(得分:1)

1。exclude module: 'support-annotations'

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

答案 1 :(得分: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'
}