【问题标题】:Error Failed to resolve: com.google.android.gms:play-services-wallet:11.4.0 [duplicate]错误无法解决:com.google.android.gms:play-services-wallet:11.4.0 [重复]
【发布时间】:2018-03-27 09:38:54
【问题描述】:

我正在尝试按照此处找到的 Google Payment API 教程进行操作: https://developers.google.com/payments/setup

我在同步 gradle 时遇到以下错误

主要是 - 我得到了错误:

无法解决:com.google.android.gms:play-services-wallet:11.4.0

错误下方有一个指向"Install Repository and sync project" 的链接,但是当我单击该链接时,没有任何反应。

有没有办法手动安装必要的存储库?还有什么我想念的吗?我什至需要安装什么存储库?我已尝试更新所有内容。

分级:

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

顶级 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
}

清单

<?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>

我一直试图让它运行大约一周,并且每当我包含谷歌钱包时都无法让 gradle 同步。我已经尽可能地遵循本教程。我已经从 github 上的示例应用程序、我自己的应用程序、从零开始的几个应用程序中尝试了它。我不知道如何让这个存储库工作。

谢谢。 约翰

【问题讨论】:

    标签: android android-gradle-plugin google-play-services android-support-library android-pay


    【解决方案1】:

    您应该将 google maven 添加到 allprojects 而不是 buildscript。所以,把它改成这样:

    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
    }
    

    【讨论】:

      【解决方案2】:

      我今天早上也遇到了同样的问题...但是解决方法是使用“11.0.4”而不是使用“11.4.0”。可能在他们的网站上出现错误,因为当您输入“11.4.0”时,Android Studio 会出现该错误,它会告诉您更新到最新版本“11.0.4”。

      总而言之,使用这个,它应该可以工作

      compile 'com.google.android.gms:play-services-wallet:11.0.4'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-04-15
        • 2017-05-10
        • 2018-11-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-09
        相关资源
        最近更新 更多