fire base and google play services can't resol

2019-07-31 02:16发布

I'm trying to build my application with the following gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '28.0.0 rc1'

defaultConfig {
    applicationId "com.wallet"
    minSdkVersion 17
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dataBinding {
    enabled = true
}
dexOptions {
    javaMaxHeapSize "4g"
}
lintOptions {
    abortOnError false
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso- 
core:2.2.2', {
    exclude group: 'com.android.support', module: 'support- 
ancom.android.supportnotations'
})
implementation('com.alibaba.android:ultraviewpager:1.0.6.1@aar') {
    transitive = true
}
implementation 'com.android.support:percent:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.koushikdutta.ion:ion:2.2.1'
implementation 'com.airbnb.android:lottie:2.5.4'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'com.orhanobut:logger:2.1.1'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.google.android.gms:play-services-ads-identifier:15.0.1'
implementation 'io.michaelrocks:libphonenumber-android:8.8.2'
implementation 'com.github.tamir7.contacts:contacts:1.1.7'
implementation 'com.cleveroad:slidingtutorial:1.0.8'
implementation "android.arch.persistence.room:runtime:1.1.1"
implementation "android.arch.lifecycle:runtime:1.1.1"
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"

implementation 'com.appyvet:materialrangebar:1.4'
implementation "com.github.nisrulz:qreader:2.1.2"

implementation project(':library')

testImplementation 'junit:junit:4.12'
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
apply plugin: 'com.google.gms.google-services'

project' gradle file:

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

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

allprojects {
    repositories {
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url 'https://maven.google.com' }
        maven { url "https://dl.bintray.com/krazykira/maven" }
        google()
    }
}

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

I'm getting the following error:

Failed to resolve: play-services-base
Failed to resolve: play-services-ads-identifier

when I change the play-services-base version to 15.0.0 this error is fixed but when I do the same for play-services-ads-identifier there's no change. Is there anyway for me to understand what is the problem or how can I make the app work with the current versions?

Any help would be appreciated 3>

1条回答
▲ chillily
2楼-- · 2019-07-31 03:14

For reasons unknown to me, google() must appear before jcenter() in the list of repositories, as is shown in the documentation.

buildscript {
    repositories {
        google() // <== CHANGED
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
        google() // <= CHANGED
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url 'https://maven.google.com' }
        maven { url "https://dl.bintray.com/krazykira/maven" }
    }
}
查看更多
登录 后发表回答