2016-11-07 16 views
1

私はFirebaseを自分のアプリケーションと統合しています。このため私はそこにアカウントを作成し、そこにアプリを作成しました。 私はそれに必要なすべての要件を実行し、アンドロイドアプリのbuild.gradleファイルも変更しました。アプリケーションでcom.google.firebase.databaseをインポート中にエラーが発生しました。

私はこのリンクを辿っており、このリンクですべての質問をしています。

{ 
    "rules": { 
    ".read": true, 
    ".write": true 
    } 
} 

今、私はUserクラスを作成し、この文を試してみたい場合:次のように今、私はデータベースのルールを設定している http://www.androidhive.info/2016/10/android-working-with-firebase-realtime-database/

輸入com.google.firebase.database.DatabaseReferenceを。

データベースクラスでエラーが発生しています。 私は、アプリケーションで簡単にインポートしてから、Firebaseが提供するデータベースサービスを使用するだけで、何をする必要がありますか?あなたはすべてのサブプロジェクト/モジュールに共通する設定オプションを追加することができます

マイBuild.gradle

//トップレベルのビルドファイル。

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" 

    defaultConfig { 
     applicationId "com.example.hsports.galleryusingimageswitcher" 
     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' 
} 

apply plugin: 'com.google.gms.google-services' 
+0

あなたのbuild.gradleを表示できますか? –

+0

私は質問を編集し、上に書いた。見てください。 –

答えて

0

あなたは公式Firebaseをチェックする必要がありますdocumentation

そこには、アプリレベルのビルドにcompile 'com.google.firebase:firebase-database:9.8.0'を追加する必要があることがわかります。 Androidでfirebase DBを使用するためのgradle。

+0

ここで2つのエラーが発生しています:compile解決に失敗しました: 'com.google.firebase:firebase-database:9.8.0' –

+0

@ shikher.mishra Firebase 9.8を使用するために最新のビルドツールを使用する必要があると思います。 0の場合、最新のビルドツールを使用できない/したくない場合は、firebase 9.6.1 – flapedriza

関連する問題