2017-06-19 18 views
0

私はAndroidプログラミングには新しく、インターン開発者として働いています。Firebaseを使用して私のアプリケーションにログインできません

私は現在、ログイン画面を実行しようとしているFirebase認証に取り組んでいます。

Firebaseにユーザーを追加しました。電子メールまたはpwを保存すると、プログラムは「電子メールとpwの両方を入力してください」というエラーを正しく表示します(私の言語で表示されます)。しかし、私がボタンをクリックすると、何も起こりません。文字通り何もない。

パッケージcom.example.jalea.requestingform;

import android.content.Intent; 
import android.preference.EditTextPreference; 
import android.support.annotation.NonNull; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.text.TextUtils; 
import android.util.Log; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Toast; 

import com.google.android.gms.tasks.OnCompleteListener; 
import com.google.android.gms.tasks.Task; 
import com.google.firebase.auth.AuthResult; 
import com.google.firebase.auth.FirebaseAuth; 

public class MainActivity extends AppCompatActivity { 
    EditText edt_email,edt_sifre; 
    Button bt_giris; 
    private FirebaseAuth mAuth; 
    private FirebaseAuth.AuthStateListener authStateListener; 



    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     edt_email = (EditText) findViewById(R.id.et_mail); 
     edt_sifre = (EditText) findViewById(R.id.et_sifre); 
     bt_giris = (Button) findViewById(R.id.btn_giris); 
     mAuth = FirebaseAuth.getInstance(); 
     authStateListener = new FirebaseAuth.AuthStateListener() { 
      @Override 
      public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { 
       if(firebaseAuth.getCurrentUser() !=null){ 
        Intent intent = new Intent(MainActivity.this,RequestActivity.class); 
        startActivity(intent); 
       } 
       else{ 
        Log.w("1 : ", "onAuthStateChanged:signed_out"); 
       } 
      } 
     }; 
     bt_giris.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       SignIn(); 
      } 
     }); 
    } 

    @Override 
    protected void onStart() { 
     super.onStart(); 
     mAuth.addAuthStateListener(authStateListener); 
    } 

    @Override 
    protected void onStop() { 
     super.onStop(); 
     if(authStateListener != null) { 
      mAuth.removeAuthStateListener(authStateListener); 
     } 
    } 
    public void SignIn(){ 
     String email = edt_email.getText().toString(); 
     String sifre = edt_sifre.getText().toString(); 

     if(TextUtils.isEmpty(email) || TextUtils.isEmpty(sifre)){ 
      Toast.makeText(MainActivity.this,"Kullanıcı adı veya şifre alanı boş",Toast.LENGTH_LONG).show(); 
     } 
     else{ 
      mAuth.signInWithEmailAndPassword(email,sifre).addOnCompleteListener(new OnCompleteListener<AuthResult>() { 
       @Override 
       public void onComplete(@NonNull Task<AuthResult> task) { 
        if(!task.isSuccessful()){ 
         Toast.makeText(MainActivity.this,"Auth. Problem",Toast.LENGTH_LONG).show(); 
        } 
       } 
      }); 
     } 



    } 
} 

これはXMLファイルです:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.jalea.requestingform.MainActivity" 
    android:padding="16dp"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="e-mail" 
     android:id="@+id/et_mail" 
     android:layout_marginTop="120dp"/> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:hint="sifre" 
     android:id="@+id/et_sifre" 
     android:layout_marginTop="20dp"/> 
    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Giriş" 
     android:layout_marginTop="20dp" 
     android:id="@+id/btn_giris"/> 

</LinearLayout> 

私はFirebaseでユーザーを追加しました。電子メールまたはpwを保存すると、プログラムは「電子メールとpwの両方を入力してください」というエラーを正しく表示します。しかし、ボタンをクリックしても何も起こりません。文字通り、何も。

6月19日05:16:37.143 2453から2453/com.example.jalea.requestingform I /技術: 後期可能-Xcheck:JNI 6月19日05:16:37.144 2453から2453/com.example.jalea.requestingform W/art:デフォルトを使用するX86の予期しないCPUの変形:x86 06-19 05:16:37.729 2453-2453/com.example.jalea.requestingform W/System:ClassLoaderが未知のパス参照: /data/app/com.example.jalea.requestingform-2/lib/x86 06-19 05:16:38.415 2453-2475/com.example.jalea.requestingform W/DynamiteModule: comのローカルモジュール記述子クラス。 google.firebase.authが見つかりません。 06-19 05:16:38.440 2453-2475/com.example.jalea.requestingform W/GooglePlayServicesUtil:Google Playストアがありません。 06-19 05:16:38.484 2453-2453/com.example.jalea.requestingform W/InstanceID/Rpc:REGISTERインテントの解決に失敗しました 06-19 05:16:38.492 2453-2453/com.example .jalea.requestingform W/InstanceID/Rpc:Google Playサービスと従来のGSFパッケージの両方が ありません。 06-19 05:16:38.493 2453-2453/com.example.jalea.requestingform D/FirebaseApp:com.google.firebase .FirebaseCrashはリンクされていません。 初期化をスキップします。 06-19 05:16:38.637 2453-2453/com.example.jalea.requestingform I/FA:アプリ測定開始、バージョン:10084 06-19 05:16:38.637 2453-2453/com.example jalea.requestingform I/FA:デバッグログを有効にするには:adbシェルsetprop log.tag.FA VERBOSE 06-19 05:16:38.637 2453-2453/com.example.jalea.requestingform D/FA:デバッグレベルメッセージロギングが有効になっている 06-19 05:16:38.637 2453-2453/com.example.jalea.requestingform D/FA:AppMeasurementシングルトンハッシュ:23426705 06-19 05:16:38.733 2453-2453/com.example.jalea .requestingform V/FA:コレクション有効 06-19 05:16:38.740 2453-2453/com.example.jalea.requestingform V/FA:アプリパッケージ、google app id:com.example.jalea.requestingform、 1: 274099860490:アンドロイド:14b27427a401eb21 06-19 05:16:38.740 2453-2453/com.example.jalea.requestingform I/FA:デバッグモードのイベントロギングを高速化するには、 adbシェルsetprop debug.firebase.analytics.app com.example.jalea .requestingform 06-19 05:16:38.902 2453-2453/com.example.jalea.requestingform V/FA:登録アクティビティライフサイクルコールバック 06-19 05:16:38.907 2453-2453/com.example.jalea.requestingform I/FirebaseInitProvider:FirebaseAppの初期化成功 06-19 05:16:38.909 2453-2453/com.example.jalea.requestingform I/InstantRun:インスタント・ラン・サーバーの起動:メイン・プロセス 06-19 05:16:38.946 2453- 2479/com.example。jalea.requestingform V/FA:ローカルアプリ測定サービスを使用しています 06-19 05:16:39.066 2453-2453/com.example.jalea.requestingformアンドロイド4.1の前に、メソッド android.graphics.PorterDuffColorFilter アンドロイド。 support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter、 android.content.res.ColorStateList、android.graphics.PorterDuff $モード) が誤っ android.graphics.drawableパッケージプライベートメソッドをオーバーライドしているだろう.Drawable 06-19 05:16:39.088 2453-2453/com.example.jalea.requestingform V/FA:onActivityCreated 06-19 05:16:39.273 2453-2479/com.example.jalea.requestingform V/FA :ローカルアプリ測定サービスの使用 06-19 05:16:39.273 2453-2479/com.ex ample.jalea.requestingform V/FA:既に接続が試行されています 06-19 05:16:39.276 2453-2479/com.example.jalea.requestingform V/FA:アクティビティが再開された時刻:1695486
[06-19 05:16:39.360 2453:16:2453 D /]
HostConnection ::取得()新規ホスト接続が06から19 05 [TID 、0xe24237c0を確立39.373 2453:2453 W /]
プロセスパイプは を失敗しました06-19 05:16:39.383 2453-2453/com.example.jalea.requestingform V/FA:ローカルAppMeasurementServiceが起動しています 06-19 05:16:39.391 2453-2453/com.example.jalea.requestingform W/1 :: onAuthStateChanged:signed_out 06-19 05:16:39.532 2453-2482/com.example.jalea.requestingform D/libEGL:エミュレータがホストGPUをサポートしていて、qemu.glesが1に設定されています。 06-19 05:16:39.533 2453-2482/com.example .jalea.requestingform E/libEGL:load_driver(/system/lib/egl/libGLES_emulation.so):dlopen 失敗:ライブラリ "/system/lib/egl/libGLES_emulation.so"が見つかりません 06-19 05:16:39.538 2453-2482/com.example.jalea.requestingform D/libEGL:loaded /system/lib/egl/libEGL_emulation.so 06-19 05:16:39.544 2453-2482/com.example.jalea.requestingform D/libEGL: /system/lib/egl/libGLESv1_CM_emulation.so 06-19 05:16:39.576 2453-2482/com.example.jalea.requestingform D/libegL:loaded /system/lib/egl/libGLESv2_emulation.so 06-19 05:16:39.624 2453-2453/com.example.jalea.requestingform V/FA:IMeasurementServiceインターフェイスにバインド 06-19 05:16:39.627 2453-2479/com.example.jalea.requestingform V/FA:サービスに接続 06-19 05:16:39.628 2453-2479/com.example.jalea.requestingform V/FA :キューイングされたサービスタスクの処理:2 06-19 05:16:39.821 2453-2453/com.example.jalea.requestingform Android 4.1以前は、メソッドint android.support.v7.widget.ListViewCompat.lookForSelectablePosition (int型、 ブール値)が誤ってandroid.widget.ListView
6月19日05でパッケージのプライベートメソッド をオーバーライドしているだろう:16:39.901 2453:0xe2423d40設立2482 D /] HostConnection ::取得()新しいホスト接続、tid 06-19 05:16:39.904 2453-2479/com.example.jalea.requestingform I/FA:T彼のインスタンスはアップローダーとしてマークされています 06-19 05:16:39.947 2453-2479/com.example.jalea.requestingform D/FA:広告IDを取得できません:java.lang.NullPointerException: 仮想メソッド ' java.lang.String com.google.android.gms.ads.identifier.AdvertisingIdClient $ Info.getId() 'nullオブジェクトリファレンスの : com.google.android.gms.internal.zzatl.zzfK(不明な情報源) 06-19 05:16:39.951 2453-2482/com.example.jalea.requestingform I/OpenGLRenderer:初期化済みEGLバージョン1.4 06-19 05:16:39.952 2453-2482/com.example.jalea.requestingform D/OpenGLRenderer:スワップ動作1 06-19 05:16:40.080 2453-2482/com.example.jalea。requestingform E/EGL_emulation:TID 2482:eglSurfaceAttrib(1174):エラー0x3009 (EGL_BAD_MATCH) 6月19日05:16:40.080 2453から2482/com.example.jalea.requestingformのW/OpenGLRenderer:表面 にEGL_SWAP_BEHAVIORの設定に失敗しました0xf347c320、エラー= EGL_BAD_MATCH 06-19 05:16:40.891 2453-2453/com.example.jalea.requestingform I/Choreographer:スキップされた60フレーム!アプリケーションがメインスレッドで多くの作業を行っている可能性があります。 06-19 05:16:44.904 2453-2479/com.example.jalea.requestingform V/FA:非アクティブ、サービスからの切断 06-19 05:16:44.909 2453-2453/com.example.jalea.requestingform V/FA:onUnbindはインテントを呼び出しました。アクション: com.google.android.gms.measurement.START 06-19 05:16:44.920 2453-2453/com.example.jalea.requestingform V/FA:ローカルAppMeasurementServiceがシャットダウンしています 06-19 05:16 :49.286 2453-2479/com.example.jalea.requestingform V/FA:セッション開始、時間:1705500 06-19 05:16:49.295 2453-2479/com.example.jalea.requestingform I/FA:タグマネージャは見つからないため使用されません 06-19 05:16:49.307 2453-2479/com.example.jalea.requestingform D/FA:ロギングイベント(FE):_s、Bundle [{_ o = auto、_sc = MainActivity 、 _si = -6096220152962165033} 06-19 05:16:49.395 2453-2479/com.example.jalea.requestingform V/FA:ローカルアプリ測定サービスを使用 06-19 05:16:49.414 2453-2453/com.example.jalea.requestingform V/FA:ローカルAppMeasurementServic eは起動中 06-19 05:16:49.417 2453-2453/com.example.jalea.requestingform V/FA:IMeasurementServiceインターフェイスにバインド 06-19 05:16:49.420 2453-2479/com.example.jalea .requestingform V/FA:サービスに接続 06-19 05:16:49.420 2453-2479/com.example.jalea.requestingform V/FA:キューイングされたサービスタスクの処理:1 06-19 05:16:49.512 2453 -2479/com.example.jalea.requestingform V/FA:ロギングイベント: 起源=自動、名前= _s、params =バンドル[mParcelledData.dataSize = 108] 06-19 05:16:49.584 2453-2479/com .example.jalea.requestingform V/FA:イベント、名前、データサイズの保存:_s、58 06-19 05:16:49.588 2453-2479/com.example.jalea.requestingform V/FA:イベント記録:イベント{ appId = 'com.example.jalea.requestingform'、 name = '_ s'、params = Bundle [{_ o =自動、_sc = MainActivity、 _si = -6096220152962165033}]} 06-19 05:16:49.660 2453-2479/com.example.jalea.requestingform V/FA:アップロードスケジュールは約ms:2103350 06-19 05 :16:49.671 2453-2479/com.example.jalea.requestingform V/FA:バックグラウンドイベント処理時間、ms:160 06-19 05:16:53.330 2453-2453/com.example.jalea.requestingform W/IInputConnectionWrapper :finishComposingText on inactive InputConnection 06-19 05:16:54.519 2453-2479/com.example.jalea.requestingform V/FA:非アクティブ、サービスからの切断 06-19 05:16:54.524 2453-2453/com .example.jalea.requestingform V/FA:onUnbindがインテントを呼び出しました。アクション: com.google.android.gms.measurement.START 06-19 05:16:54.534 2453-2453/com.example.jalea.requestingform V/FA:ローカルAppMeasurementServiceがシャットダウンしています 06-19 05:16 :58.759 2453-2475/com.example.jalea.requestingform W/DynamiteModule:ローカルモジュール記述子クラス com.google.firebase.authが見つかりません。 06-19 05:16:58.764 2453-2475/com.example.jalea.requestingform W/GooglePlayServicesUtil:Google Playストアがありません。 06-19 05:17:00.113 2453-2475/com.example.jalea.requestingform W/DynamiteModule: のローカルモジュール記述子クラスcom.google.firebase.authが見つかりません。 06-19 05:17:00.116 2453-2475/com.example.jalea.requestingform W/GooglePlayServicesUtil:Google Playストアがありません。

+0

があなたである起動されます6文字以上のパスワード? –

+0

はい、8文字です。 –

答えて

1

あなたのGradleで、次の(依存関係)

コンパイル 'com.google.android.gms:遊ぶ - サービス - 広告:9.4.0' 追加されていることを確認してください

をコンパイル 'com.google.firebase:firebaseコア:9.4.0'

(認証)あなたは firebaseコンソールでパスワードログインを有効にしていることを確認してください

電子メールおよびPWD

FirebaseAuth mAuth = FirebaseAuth.getInstance(); // same auth as you used for regestration process 
mAuth.signInWithEmailAndPassword("[email protected]","pwd") 
       .addOnCompleteListener(new OnCompleteListener<AuthResult>() { 
        @Override 
        public void onComplete(@NonNull Task<AuthResult> task) { 
         if(task.isSuccessful()){ 

         } 

        }}) 
       .addOnFailureListener(new OnFailureListener() { 
        @Override 
        public void onFailure(@NonNull Exception e) { 

         Toast.makeText(LoginActivity.this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); 
        } 
       }); 

とログイン用のコードの下

使用あなたが成功した認証の変更のリスナーよりログインします

Authの変更LISTNER

private FirebaseAuth.AuthStateListener mAuthListener; 
mAuthListener = new FirebaseAuth.AuthStateListener() { 
      @Override 
      public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { 
       FirebaseUser user = firebaseAuth.getCurrentUser(); 
       if(user !=null){ 

       } 
      } 
     }; 


mAuth.addAuthStateListener(mAuthListener); 
+0

私は簡単なGoogleのログインをしました。 Firebaseコンソールでユーザを取得するには、Firebaseで何かする必要がありますか?ログイン作業は何もないので、 – soommy12

+0

Firebaseサービスの使用を開始する前に、サーバー側とアプリケーション側で、Firebaseを正しく設定するために必要ないくつかのことがあります。 Gmailアカウントを既にお持ちの場合は、console.firebase.google.comにアクセスし、Gmailアカウントでサインインするだけです...サインインした後、メインに移動しますコンソール...あなたが作成したすべてのプロジェクトをリストしています...もしあなたがいれば... –

+0

ええ、私は自分自身をすでに理解しています。正直に言うと、それほど難しくありませんでした。 Firebaseは素晴らしいシンプルなバックエンドサーバです! – soommy12

関連する問題