-1

facebookとgoogleを使用してログイン用のアプリケーションを作成するためのチュートリアルに従っています。 facebookアプリケーションがクラッシュするここでFacebookやGoogleアカウントを使用してログインするとアプリケーションがクラッシュする

は私のMainActivity

public class MainActivity extends AppCompatActivity implements View.OnClickListener{ 

private static final int RC_SIGN_IN=0; 
FirebaseAuth auth; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    FirebaseAuth auth=FirebaseAuth.getInstance(); 

    if(auth.getCurrentUser()!=null) 
    { 
     Log.d("AUTH",auth.getCurrentUser().getEmail()); 
    } 
    else { 
     startActivityForResult(AuthUI.getInstance() 
       .createSignInIntentBuilder().setProviders(
         AuthUI.FACEBOOK_PROVIDER, 
         AuthUI.GOOGLE_PROVIDER, 
         AuthUI.EMAIL_PROVIDER 

       ).build(), RC_SIGN_IN); 
    } 

    findViewById(R.id.btnLogout).setOnClickListener(this); 
} 
@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    if(requestCode==RC_SIGN_IN) 
    { 
     if(resultCode==RESULT_OK) 
     { 
      Log.d("AUTH",auth.getCurrentUser().getEmail()); 
     } 
     else 
     { 
      Log.d("AUTH","Not authenticated"); 
     } 
    } 
} 

@Override 
public void onClick(View view) { 
    if(view.getId()==R.id.btnLogout) 
    { 
     AuthUI.getInstance().signOut(this).addOnCompleteListener(new OnCompleteListener<Void>() { 
      @Override 
      public void onComplete(@NonNull Task<Void> task) { 
       Log.d("AUTH","User logged Out"); 
       finish(); 
      } 
     }); 
    } 
} 

}

build.gradle(アプリ)が

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.example.ranjit.authenticate" 
     minSdkVersion 18 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
     multiDexEnabled = true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 

    compile 'com.firebaseui:firebase-ui-auth:0.4.4' 
    compile 'com.android.support:appcompat-v7:25.1.0' 
    compile 'com.google.firebase:firebase-auth:10.0.1' 
    compile 'com.google.android.gms:play-services-auth:10.0.1' 
    testCompile 'junit:junit:4.12' 
} 

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

を提出し、以下のアプリケーション

08-21 03:09:24.419 23408-23408/com.example.ranjit.authenticate E/AndroidRuntime: FATAL EXCEPTION: main 
                      Process: com.example.ranjit.authenticate, PID: 23408 
                      java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { }} to activity {com.example.ranjit.authenticate/com.example.ranjit.authenticate.MainActivity}: java.lang.NullPointerException 
                       at android.app.ActivityThread.deliverResults(ActivityThread.java:3532) 
                       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3575) 
                       at android.app.ActivityThread.access$1300(ActivityThread.java:139) 
                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341) 
                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                       at android.os.Looper.loop(Looper.java:149) 
                       at android.app.ActivityThread.main(ActivityThread.java:5257) 
                       at java.lang.reflect.Method.invokeNative(Native Method) 
                       at java.lang.reflect.Method.invoke(Method.java:515) 
                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
                       at dalvik.system.NativeStart.main(Native Method) 
                       Caused by: java.lang.NullPointerException 
                       at com.example.ranjit.authenticate.MainActivity.onActivityResult(MainActivity.java:50) 
                       at android.app.Activity.dispatchActivityResult(Activity.java:5603) 
                       at android.app.ActivityThread.deliverResults(ActivityThread.java:3528) 
                       at android.app.ActivityThread.handleSendResult(ActivityThread.java:3575)  
                       at android.app.ActivityThread.access$1300(ActivityThread.java:139)  
                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)  
                       at android.os.Handler.dispatchMessage(Handler.java:102)  
                       at android.os.Looper.loop(Looper.java:149)  
                       at android.app.ActivityThread.main(ActivityThread.java:5257)  
                       at java.lang.reflect.Method.invokeNative(Native Method)  
                       at java.lang.reflect.Method.invoke(Method.java:515)  
                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)  
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)  
                       at dalvik.system.NativeStart.main(Native Method)  

08のための私のlogcatであります-21 03:09:30。 779 23408-23421/com.example.ranjit.authenticate W/DynamiteModule:com.google.firebase.authのローカルモジュール記述子クラスが見つかりません。

答えて

1

このメソッドでは、NULLポインタ例外があります。 それはおそらくあなたが認証

 Log.d("AUTH",auth.getCurrentUser().getEmail() 
にアクセスする方法です
関連する問題