Android 未能解析:com.google.firebase:firebase核心:16.0.0
我有一个android项目 我想使用google firebase向该应用程序添加推送通知 首先,我下载了xml文件,然后在approot上通过它 正如他们在这个链接上说的那样,我添加了这行代码Android 未能解析:com.google.firebase:firebase核心:16.0.0,android,firebase,android-studio,Android,Firebase,Android Studio,我有一个android项目 我想使用google firebase向该应用程序添加推送通知 首先,我下载了xml文件,然后在approot上通过它 正如他们在这个链接上说的那样,我添加了这行代码 buildscript { dependencies { // Add this line classpath 'com.google.gms:google-services:4.0.0' } } dependencies { // Add this line c
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插件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
,从compile
到implementation
,因为它们很快就会被弃用。我注意到你需要更新很多脚本
例如,让我们从顶级的build.gradle
开始。您不应该再使用android gradle插件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
,从compile
到implementation
,因为它们很快就会被弃用。你必须为所有项目添加google()google的Maven存储库
allprojects {
repositories {
jcenter()
google()
}
}
您必须为所有项目添加google()google的Maven存储库
allprojects {
repositories {
jcenter()
google()
}
}
我在build.gradle[Proyect]中用这个脚本解决了这个问题
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
maven {
url 'https://dl.bintray.com/android/android-tools'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}
我在build.gradle[Proyect]中用这个脚本解决了这个问题
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
maven {
url 'https://dl.bintray.com/android/android-tools'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}
能否显示完整的
build.gradle
?可能您忘记将jcenter()
和google()
放在构建脚本存储库中。更新了问题:这都是您的顶级build.gradle
?不是应用程序级别,而是项目/顶级build.gradle
yes,我添加了一个新的gradle文件。如果它对您的项目有效,请接受答案。:)能否显示完整的build.gradle
?可能您忘记将jcenter()
和google()
放在构建脚本存储库中。更新了问题:这都是您的顶级build.gradle
?不是应用程序级别,而是项目/顶级build.gradle
yes,我添加了一个新的gradle文件。如果它对您的项目有效,请接受答案。:)