我创建了一个Android项目,我必须使用数据库来存储信息。我必须在其中创建表格,以便客户端使用Firebase中的新数据使用该应用程序。我在Firebase中创建了一个帐户,并在gradle文件中写下了所有需要的内容。
Build.gradel文件(项目文件)
// 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:1.5.0'
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
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
的build.gradle(模块:应用)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
packagingOptions{
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
defaultConfig {
applicationId "com.example.hsports.bandpop"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
当我点击同步按钮进行同步时,它会给我这个错误。
Error:Failed to resolve: com.google.firebase:firebase-core:9.6.1
<a href="openFile:C:/Users/I324671/AndroidStudioProjects/BandPop/app/build.gradle">Open File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Error:(26, 13) Failed to resolve: com.google.firebase:firebase-storage:9.6.1
<a href="openFile:C:/Users/I324671/AndroidStudioProjects/BandPop/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
答案 0 :(得分:1)
我想你错过了 packagingOptions { 排除&#39; META-INF / LICENSE&#39; 排除&#39; META-INF / LICENSE-FIREBASE.txt&#39; 排除&#39; META-INF / NOTICE&#39; 在BuildTypes {} tag
之上的Build.gradle(module:app)文件中答案 1 :(得分:0)
您还需要添加提到的缺失依赖项:
compile 'com.google.firebase:firebase-storage:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'