无法解析:com.google.firebase:firebase-core:16.0.0 [英] failed to resolve: com.google.firebase:firebase-core:16.0.0

查看:223
本文介绍了无法解析:com.google.firebase:firebase-core:16.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有android项目 我想使用Google Firebase向该应用程序添加推送通知 首先,我下载了xml文件,并将其粘贴到应用程序根目录中,然后 我按照他们在此链接上所说的那样添加了这些行

i have android project and i want to add push notifications to that app using google firebase first i downloaded the xml file and past it on app root then i added this lines as they said on this link

buildscript {
  dependencies {
    // Add this line
    classpath 'com.google.gms:google-services:4.0.0'
  }
}
    dependencies {
  // Add this line
  compile 'com.google.firebase:firebase-core:16.0.0'
}
...
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

,我现在单击同步 总是会出现此错误

and i click sync now always gat this error

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

感谢帮助 这是完整的gradle文件

thank for help this is the full gradle file

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "28.0.0"
    defaultConfig {
        applicationId "com.softya.demo"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-core:16.0.0'
}
apply plugin: 'com.google.gms.google-services'

这是gradle文件代码

and this is the gradle file code

    // 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.3.0'
        classpath 'com.google.gms:google-services:4.0.0'
        // 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
}

推荐答案

我注意到您需要更新很多脚本.

I notice you need to updates a lot of your scripts.

例如,让我们从顶级build.gradle开始.您不应再使用android gradle插件2. +,而应使用版本3.1.x

For example, let's start with your top-level build.gradle. You should no longer use android gradle plugin 2.+, instead you should use version 3.1.x

为此,您应该将google()放入存储库中.

And to do that, you should put google() in your repositories.

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

buildscript {
   repositories {
      jcenter()
      //Add this line
      google()
   }
   dependencies {
      //Please update it to 3.1.x
      classpath 'com.android.tools.build:gradle:3.1.2'
      //Update to the latest version as well
      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
   }
}

一些提示:

请尝试将您的应用程序级别build.gradlecompile更新到implementation,因为它们很快就会被弃用.

Try to update your app-level build.gradle, from compile to implementation since they will be deprecated soon.

这篇关于无法解析:com.google.firebase:firebase-core:16.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆