0

I got this error and tried to clean the project and rebuild it also. But it is not working.
And also I tried to remove some codes from gradle but still not working.

Please advise.
Thanks.

Error:

enter image description here

This is 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.1.2'
//        classpath 'com.google.gms:google-services:1.3.0-beta1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion '20.0.0'
}
dependencies {
}

This is from app\build.gradle

apply plugin: 'com.android.application'
//apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "me.kevingleason.pubnubchat"
        minSdkVersion 15
        targetSdkVersion 21
        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.pubnub:pubnub-android:3.7.4'
    compile 'com.google.android.gms:play-services:7.5.0'
}
Dimitar
  • 4,402
  • 4
  • 31
  • 47
User
  • 13
  • 6

2 Answers2

0

Try the following, and see if it works. Also, provide me with the version of android studio you're using and build tools version.

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.1.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
}

app/build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion '24.0.0' //replace with your buildtoolsversion here

defaultConfig {
    applicationId "me.kevingleason.pubnubchat"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    provided 'com.android.support:support-annotations:23.3.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.google.android.gms:play-services:9.0.2'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.pubnub:pubnub-android:3.7.4' //erase if error is given and recompile
}
ChrisF
  • 134,786
  • 31
  • 255
  • 325
masterplox
  • 41
  • 7
0

You problem is firstly the second dependencies in your outer buil.gradle. That is actually exactly the 19th line from the error message. Delete it (at the end of the first):

dependencies {
}

Then there is a NOTE comment some lines above stating:

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

So as a rule of thumb remember to always put your dependencies in the app-module's build.gradle and not the project's one.

Hope you find this helpful.

Dimitar
  • 4,402
  • 4
  • 31
  • 47