我正在构建一个在 Firebase 系统中使用的应用程序。当我开始在我的应用程序中输入 Firebase 的代码时,出现了这个错误:
"Error:(30, 13) Failed to resolve: com.google.firebase:firebase-core:12.0.1
<a href="openFile:C:/Users/Public/Documents/Jtube2/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>"
我查找了这个错误并找到了 this但我检查了我的 SDK 管理器,一切正常我不知道我的代码有什么问题。
这是我的 build.gradle (module:app) 代码:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-vector-drawable:25.1.0'
compile 'com.google.firebase:firebase-core:12.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
这里是我的 build.gradle (Project:myproject) 代码:
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
有人可以帮帮我吗?
最佳答案
您需要在 project build.gradle
的 allProjects
block 中添加 google()
maven像这样:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
...
}
}
repositories {
...
}
// You need to add the google maven in this block.
allprojects {
repositories {
jcenter()
google()
}
}
关于java - Firebase 设置-错误 : Failed to resolve: com. google.firebase :firebase-core:12. 0.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49942413/