2016-05-30 12 views
0

Firebaseを使用しようとしていて、サーバの設定に問題がありました。Firebaseを使用した.setServiceAccountメソッドがありません

ドキュメントに続いて、私はこのコードを見つけました。

FirebaseOptions options = new FirebaseOptions.Builder() 
.setServiceAccount(new FileInputStream("path/to/ serviceAccountCredentials.json")) 
.setDatabaseUrl("https://databaseName.firebaseio.com/") 
.build(); 

    FirebaseApp.initializeApp(options); 

私の問題は、私が方法が誤りであることを私に知らせるIDEでエラーを取得していますので、setServiceAccount方法は、サポートされていないようで、あります。 Firebaseのドキュメントに行くと、.setServiceAccountというメソッドがないようです。同じような問題がinitializeAppメソッドで発生しました。引数オプションにエラーがあるようでした。

ここにも同様のトピックがあるようです。 build.gradeから コマンドCompile time error for setServiceAccount() with FirebaseOptions.Builder()

が、ユーザの一方が コンパイル ':firebaseサーバ-SDK [3.0.0)com.google.firebase' を除去することをお勧めします。残念ながら、私にとってはまだ問題は残っています。何が問題なの?

私のbuild.gradleは、次のようになります。

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.2.0' 

compile 'com.google.firebase:firebase-messaging:9.0.1' 
compile 'com.google.firebase:firebase-core:9.0.1' 
compile 'com.google.firebase:firebase-storage:9.0.1' 
compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)' 

compile 'com.google.android.gms:play-services-appindexing:9.0.1' 
} 

答えて

0

あなただけcompile 'com.google.firebase:firebase-server-sdk:[3.0.0,)'依存関係を使用して削除する必要があります。他の人がクライアントSDKありながら

compile 'com.google.firebase:firebase-messaging:9.0.1' 
compile 'com.google.firebase:firebase-core:9.0.1' 
compile 'com.google.firebase:firebase-storage:9.0.1' 

最初は、サーバーのSDKで、それらを一緒に使用しようとすると、競合します。

+0

ありがとうございます。残念ながら、問題は依然として続きます。私は最近、提案されたアイテムを削除し、 'com.google.android.gms:play-services-appindexing:9.0.1' をコンパイルして残しました。 'com.google.firebase:firebase-server-sdk:[3.0.0、 ) ' – Czar

+0

あなたはgradle syncを実行しようとしましたか、IDEがそのキャッシュを更新するのを助けるために(その行をコメントで)コンパイルしましたか? –

+0

はい、私はこれらの2本の線で同期をクリックしました。私はあなたが「コンパイルする(その行でコメントした)」と言うときは分かりません。その外観から、setServiceAccountはサポートされなくなったようですが、Firebaseのドキュメントには表示されません:https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseOptions.Builder #public-constructor-summary – Czar

関連する問題