4

I try to add library google play service to project via Maven in android studio, but it get many issues.

First Issue is Multiple dex files define :

repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.google.android.gms:play-services:+'
}

I researched, changed to like this:

    repositories {

        mavenCentral()
}

    dependencies {

        compile fileTree(dir: 'libs', include: '*.jar')
       // compile 'com.google.android.gms:play-services:+'

        compile 'com.google.android.gms:play-services:4.3.23'{
         exclude module: 'support-v4'
}

       compile 'com.android.support:support-v4:18.0.+'

    }

But I get other error Build script error, unsupported Gradle DSL method found: 'com.google.android.gms:play-services:4.3.23()'!

I don't why I got this bug.

People can tell me how to add library google play service to project via Maven successfully?

Thanks,

Dong Le
  • 107
  • 2
  • 12

3 Answers3

0

I must modify my build.gradle file to look like this:

repositories {
    mavenCentral()
}
dependencies {

    compile 'com.google.android.gms:play-services:+'
}

Restart android studio and synchronize my project. Problem solved

Thanks all everybody

I understand about add library google play service in android studio when I following link: Android Studio with Google Play Services

Community
  • 1
  • 1
Dong Le
  • 107
  • 2
  • 12
0

Right Click on you App, then Open Module Settings

  1. Right Click on your App
  2. Click Open Module Settings
  3. Select the Dependencies tap
  4. Select the green plus(+) button to add dependencies
  5. Select Library Dependency
  6. Play Services
  7. Sync Gradle
eliteslayer
  • 190
  • 6
-1

Here is what the top of my build.gradle file looks like:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

dependencies {
    // http://gradleplease.appspot.com/
    compile 'com.google.android.gms:play-services:4.3.23'
    compile 'com.googlecode.android-query:android-query:0.25.9'
    compile 'com.android.support:support-v13:19.0.1'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.jsoup:jsoup:1.7.3'
    compile 'org.apache.commons:commons-io:1.3.2'
    compile files('libs/libGoogleAnalyticsServices.jar')
}

As mentioned in the comment in dependencies, you can get the latest version of a lot of these by going to http://gradleplease.appspot.com/

Kyle Falconer
  • 8,302
  • 6
  • 48
  • 68