-3

私のデータはAndroid経由でAndroid Firebaseに保存されていますが、保存ボタンをクリックするとアプリがクラッシュします。私は何をすべきか?私は多くを検索しましたが、満足のいく回答は得られませんでした。マイ設定 依存関係の適用{Androidファイアベースデータの認証済みユーザによる書き込み

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.firebase:firebase-client-android:2.4.0' 

compile 'com.google.firebase:firebase-auth:10.0.1' 

compile 'com.google.firebase:firebase-core:10.0.1' 

compile 'com.google.firebase:firebase-database:10.0.1' 

compile 'com.google.firebase:firebase-storage:10.0.1' 

compile 'com.firebaseui:firebase-ui-database:0.4.0' 

} Firebase

apply.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 

      //progressBar.setVisibility(View.VISIBLE); 

      Firebase fire=new Firebase(Configuration.FIREBASE_URL); 

      //Firebase userroot=fire.child(fire.getAuth().getUid()); 

      String name_s=name.getText().toString().trim(); 

      String contact_s=contact.getText().toString().trim(); 

      String blood_s=bloodgroup.getSelectedItem().toString().trim(); 
      String city_s=city.getText().toString().trim(); 
      String country_s=country.getText().toString().trim(); 

      //String password_s=password.getText().toString().trim(); 

      Information information=new Information(); 

      information.setName(name_s); 

      information.setContact(contact_s); 

      information.setBloodgroup(blood_s); 
      information.setCity(city_s); 
      information.setCountry(country_s); 

      FirebaseUser user=auth.getCurrentUser(); 
      database.child(user.getUid()).setValue(information); 

      Toast.makeText(getApplicationContext(),"You are now a DONNOR", Toast.LENGTH_LONG).show(); 

                 } 
             }); 

{"rules": { 
".read": true, 
".write": "auth != null" 
      } 
} 

Javaコードを保存するためのデータ:私はここに私の関連するコード

Firebaseルールを与えていますプラグイン: 'com.google.gms.google-services'

私はチェックしましたが、ユーザーは正常にログインしましたが、firebaseにデータを追加しようとしたときに、アプリケーションが破損しましたが、データが正常に追加されました。状況について本当に混乱しています。 ?

+0

あなたは正確なエラーが何かを推測したいのですか、それともそれほど具体的に指定できますか? – Chisko

答えて

0

私は初期化の次の方法をお勧め:あなたのユーザーが正常に(あなたがサインインプロセス用のカスタムトークンまたは資格情報を使用する場合、このほぼ同じ)で署名された場合

mFirebaseAuth = FirebaseAuth.getInstance(); mFirebaseUser = mFirebaseAuth.getCurrentUser();

をも確認してください。

mFirebaseAuth.signInWithEmailAndPassword(email, password) 
        .addOnCompleteListener(LogInActivity.this, new OnCompleteListener<AuthResult>() { 
         @Override 
         public void onComplete(@NonNull Task<AuthResult> task) { 
          if (task.isSuccessful()) { 
           //sign in successful. 
          } else { 
            //show what's gone wrong: 
           AlertDialog.Builder builder = new AlertDialog.Builder(LogInActivity.this); 
           builder.setMessage(task.getException().getMessage()) 
             .setTitle(R.string.login_error_title) 
             .setPositiveButton(android.R.string.ok, null); 
           AlertDialog dialog = builder.create(); 
           dialog.show(); 
          } 
         } 
        }); 

PSあなたのコードスニペットからFirebaseをどのようにして正確に初期化するのかを知ることは難しいです。 Configurationとは何ですか?

+0

post.pleaseを更新しました。ちょっと見て、助けてください:( – Alik

+0

私はこのためにlogcatの出力を見る必要があります。 – Sevastyan

関連する問題