gpt4 book ai didi

android - 无法解析 : com. google.firebase :firebase-core:16. 0.0

转载 作者:行者123 更新时间:2023-11-29 15:35:42 25 4
gpt4 key购买 nike

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

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'

我现在点击同步总是报这个错误

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

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

    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文件代码

    // 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
}

最佳答案

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

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

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

// 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.gradle,从 compileimplementation,因为它们很快就会被弃用。

关于android - 无法解析 : com. google.firebase :firebase-core:16. 0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50789344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com