failed to resolve com.google.firebase:firebase-core:10.0.1

99封情书 提交于 2019-12-22 03:55:26

问题


I want to use Firebase Cloud Messaging in my Android App. This is my app level gradle file

apply plugin: 'com.android.application'
android {
    signingConfigs {
        config {
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        config1 {
            keyPassword 'android'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    packagingOptions {
        exclude 'main/AndroidManifest.xml'
    }
    defaultConfig {
        applicationId "com.shikhar.dexter.project"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.google.firebase:firebase-messaging:10.0.1'

    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'

    compile 'com.google.android.gms:play-services:9.0.0'
    compile 'com.google.android.gms:play-services-auth:9.0.0'

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

This is my root level gradle file

   // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.android.tools.build:gradle:2.1.0'

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

allprojects {
    repositories {
        jcenter()
        maven{
            url  "http://dl.bintray.com/dasar/maven"
        }
    }
}

While compiling it shows these Errors:

Failed to resolve: com.google.firebase:firebase-core:10.0.1

Error:(36, 13) Failed to resolve: com.google.firebase:firebase-messaging:10.0.1

I tried with various Google Play Services Versions like 9.4.0 but still it doesn't work.


回答1:


Open SDK Manager and make sure you have latest "Google Play Services" dependency downloaded.




回答2:


In addition to downloading the latest "Google Play Services" as suggested by John Oreilly above I also had to update my 'Google Repository' to get it to work.

In Android Studio go to "Tools -> Android -> SDK manager". In the SDK manager select the tab "SDK Tools" and below "Support Repository" you find 'Google Repository', upgrade it if it's not using the latest version.




回答3:


Probably needs an update of Google Play Services and Google Repository.

In Android Studio SDK Manager:

  • Select SDK Tools tab
  • Select and install Google Play Services and Google Repository
  • Sync and Build

see screenshot




回答4:


Try adding all the google dependencies of same version and keep the "Google Play Services" updated in the SDK Manager.

compile 'com.google.firebase:firebase-appindexing:10.0.0'
    compile 'com.google.android.gms:play-services-auth:10.0.0'
    compile 'com.google.android.gms:play-services-places:10.0.0'



回答5:


just had the problem, that with the update from Support Repository v44 to v45 (mid of March 2107); the repository location suddenly changed and therefore some dependencies broke, resulting in quite the same error message (the reason why I want to add this as a possible answer).

in the Project level build.gradle, the repository v44 was located at:

repositories {
    maven { url '... /sdk/extras/android/m2repository' }
}

while in the meanwhile, the repository v45 is located at:

repositories {
    maven { url '... /sdk/extras/m2repository' }
}

in order to refresh and to get debug information:

./gradlew clean --debug

even with other versions of the repository, it may help to browse the directory structure and compare the location of the repository with the location referenced in the build.gradle, which is supposed to host these dependencies.




回答6:


I Solved this problem in my computer(I use Intelij) what I did is: 1)Go to tools-> SDK manager and update the google play serve and the google repstories. 2)add to the build this maven { url "https://maven.google.com" }under allprojects->repstories



来源:https://stackoverflow.com/questions/41258616/failed-to-resolve-com-google-firebasefirebase-core10-0-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!