【问题标题】:ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-base错误:无法解析“:app@debug/compileClasspath”的依赖关系:无法解析com.google.android.gms:play-services-base
【发布时间】:2020-05-10 06:03:53
【问题描述】:

正如您所见,这是我在尝试同步项目时遇到的错误,我一次又一次地遇到这个问题。 Gradle 处于在线模式。我也尝试过离线模式,但我发现了同样的问题。

我也尝试了很多方法,但仍然无法解决这个问题。

Gradle 同步错误

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[10.2.1, 16.1.99]

Build.gradle(项目)

// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.3'



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

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


    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Build.gradle (:app)

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }

    }

    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'


repositories {
    maven { url 'https://maven.google.com' }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        vectorDrawables {
            useSupportLibrary = true
        }
        vectorDrawables.useSupportLibrary = true

        applicationId "com.game.pubg.best.tournaments"

        // TODO: Please update the OneSignal ID below to yours!
        manifestPlaceholders = [onesignal_app_id: '6554b669-a188-4110-8836-b181ff64894b',
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: 'REMOTE']

        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath false
            }
        }
    }
    repositories {
        mavenCentral()
        maven { url 'http://repo1.maven.org/maven2' }
        maven { url "http://jcenter.bintray.com" }
        maven { url "https://www.jitpack.io" }
        maven { url "https://maven.google.com" }
        maven { url 'https://dl.bintray.com/drummer-aidan/maven' }
        maven { url "https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/" }
        jcenter()
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
//        debug {
//            minifyEnabled true
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//        }
    }
}

apply plugin: 'com.google.gms.google-services'


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-vector-drawable:28.0.0'

//    implementation 'ai.devsupport.instamojo:instamojolib:0.1.6'

    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2',
            {
                exclude group: 'com.android.support', module: 'support-annotations'
            }
    )
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'


//    implementation 'com.google.android.gms:play-services-ads:17.0.0'

    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.facebook.shimmer:shimmer:0.5.0'

    implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'

    implementation 'com.github.bumptech.glide:glide:4.11.0'

    implementation 'com.onesignal:OneSignal:[3.13.0, 3.99.99]'

    implementation('com.paytm:pgplussdk:1.3.3')
            {
        transitive = true
            }

    implementation 'org.jsoup:jsoup:1.13.1'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'

}

【问题讨论】:

  • 移至 Androidx

标签: android android-studio android-gradle-plugin google-play-services build.gradle


【解决方案1】:

apply plugin: 'com.google.gms.google-services' 添加到build.gradle (:app) 试试这个问题的答案的依赖关系:Android Studio can't find Kotlin dependency

【讨论】:

  • 我收到另外两个错误:- org.gradle.api.plugins.UnknownPluginException:未找到 ID 为“com.google.gms.google-services”的插件。 groovy.lang.MissingPropertyException:无法为 org.gradle.api.Project 类型的项目“:app”获取未知属性“android”。
  • 检查您的互联网连接。也许你需要VPN。 @JyotiranjanTripathy
  • 亲爱的,你能帮帮我吗?因为我正在寻找这个 2 天,我尝试了一切。
  • 我修改了答案@JyotiranjanTripathy
  • 尊敬的先生,我没有使用 Koltin,我对此一无所知。我编辑了我的问题并更新了一些代码。请就如何解决此错误提出一些建议。
猜你喜欢
  • 2018-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-11
  • 2018-08-26
  • 1970-01-01
相关资源
最近更新 更多