Michael
Michael

Reputation: 199

gradle how to fix dependencies

This is what my 'app' code look like after changing it 10 times :

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

still not wotking and giving me errors .. how should the code here look? i updated everything to the latest version.

the errors:

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>

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

Upvotes: 1

Views: 1872

Answers (2)

Manza
Manza

Reputation: 3527

1. write exclude module: 'support-annotations'

2. follow the instructions to add support libraries: https://developer.android.com/topic/libraries/support-library/setup.html

Upvotes: 1

R. Zag&#243;rski
R. Zag&#243;rski

Reputation: 20258

If the error is :

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

Then everything you need is to modify exclusion of support-annotations as this line lacks word exclude :

Here are full dependencies:

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

Upvotes: 0

Related Questions