1

I'm trying to follow the tutorial for the Google Payment API found here: https://developers.google.com/payments/setup

I'm getting the following errors when I sync the gradle

image with errors

Mainly - I get the error:

Failed to resolve: com.google.android.gms:play-services-wallet:11.4.0

There is a link under the error to "Install Repository and sync project" but when I click that, nothing happens.

Is there a way to manually install the necessary repository? Is there something else that I'm missing? What repository do I even need to install? I've tried to update everything.

Gradle:

{
 apply plugin: 'com.android.application'

    android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.google.android.gms.samples.wallet"
        minSdkVersion 26
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
}
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
    'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.google.android.gms:play-services-wallet:11.4.0'
    compile 'com.google.android.gms:play-services-tasks:11.4.0'
    compile 'com.google.android.gms:play-services-base:11.4.0'
    compile 'com.google.android.gms:play-services-basement:11.4.0'
}

Top Level Gradle

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

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

Manifest

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name="MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!-- Enables the Google Payment API -->
    <meta-data
        android:name="com.google.android.gms.wallet.api.enabled"
        android:value="true" />
</application>

I've been trying to get this to run for about a week, and can't get the the gradle to sync whenever I include google wallet. I've followed the tutorial as closely as I can. I've tried it with their sample app from github, from my own app, from a couple apps from scratch. I have no idea how to get this repository to work.

Thanks. John

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
John Mansell
  • 624
  • 5
  • 16

2 Answers2

3

You should add the google maven to allprojects not to buildscript. So, change it to something like this:

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

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

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
0

I was having the same issue this morning as well... But the Fix is Instead of using "11.4.0" you should be using "11.0.4". Maybe an error on their website because when you put "11.4.0" Android Studio is giving you that error and it tells you to update to the latest version which is "11.0.4".

To sum up, use this one and it should work

compile 'com.google.android.gms:play-services-wallet:11.0.4'
Amazing Thing
  • 155
  • 2
  • 11