2016-11-23 89 views
4

不知道爲什麼會發生這種情況。不斷收到此錯誤使用Google登錄時出現Firebase錯誤。 12501 null

使用Google登錄時出錯。 12501 null

也是這一個。

W/DynamiteModule:未找到com.google.firebase.auth的本地模塊描述符類。

代碼:

package com.workoutwager.workoutwager; 

import android.content.Intent; 
import android.support.annotation.NonNull; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.util.Log; 
import android.widget.Toast; 

import com.firebase.ui.auth.AuthUI; 
import com.firebase.ui.auth.ui.ResultCodes; 
import com.google.firebase.auth.FirebaseAuth; 
import com.google.firebase.auth.FirebaseUser; 

import java.util.Arrays; 

public class MainActivity extends AppCompatActivity { 

    private FirebaseAuth mFirebaseAuth; 
    public static final int RC_SIGN_IN = 1; 
    private FirebaseAuth.AuthStateListener mAuthStateListener; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     mFirebaseAuth= FirebaseAuth.getInstance(); 
     mAuthStateListener = new FirebaseAuth.AuthStateListener() { 
      @Override 
      public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { 
       FirebaseUser user = firebaseAuth.getCurrentUser(); 
       if (user != null){ 
        //signed in 
        Intent intent = new Intent(MainActivity.this, LoginSuccess.class); 
        startActivity(intent); 


       } 
       else{ 
        //signed out 

        startActivityForResult(
          AuthUI.getInstance() 
            .createSignInIntentBuilder() 
            .setProviders(Arrays.asList(new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(), 
              new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(), 
              new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build())) 
            .setIsSmartLockEnabled(false) 
            .setLogo(R.drawable.logo) 
            .build(), 
          RC_SIGN_IN); 
       } 
      } 
     }; 

    } 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     if (resultCode == RESULT_OK) { 
      // user is signed in! 
      startActivity(new Intent(this, LoginSuccess.class)); 
      finish(); 
      return; 
     } 

     // Sign in canceled 
     if (resultCode == RESULT_CANCELED) { 
      startActivity(new Intent(this, MainActivity.class)); 
      return; 
     } 

     // No network 
     if (resultCode == ResultCodes.RESULT_NO_NETWORK) { 
      Toast.makeText(MainActivity.this, "You are not connected", Toast.LENGTH_LONG).show(); 
      return; 
     } 

     // User is not signed in. Maybe just wait for the user to press 
     // "sign in" again, or show a message. 
    } 
    @Override 
    protected void onPause(){ 
     super.onPause(); 
     mFirebaseAuth.removeAuthStateListener(mAuthStateListener); 

    } 
    @Override 
    protected void onResume(){ 
     super.onResume(); 
     mFirebaseAuth.addAuthStateListener(mAuthStateListener); 
    } 
} 

搖籃:

apply plugin: 'com.android.application' 
apply plugin: 'com.google.gms.google-services' 
android { 
    compileSdkVersion 24 
    buildToolsVersion "25.0.0" 
    defaultConfig { 
     applicationId "com.workoutwager.workoutwager" 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    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.android.support:appcompat-v7:24.2.1' 
    compile 'com.google.firebase:firebase-database:9.8.0' 
    compile 'com.google.firebase:firebase-auth:9.6.1' 
    compile 'com.firebaseui:firebase-ui-auth:1.0.0' 
    testCompile 'junit:junit:4.12' 
} 
+0

你在哪裏遇到這個錯誤?這是否隨機出現在您的日誌中?還是有特定的步驟來重現它? –

回答

0

有關模塊的錯誤...你檢查的prerequisites

  • 運行Android 2.3(薑餅)的設備或更新,並谷歌Play服務10.0.0或更新

  • 的谷歌存儲庫從Android SDK管理器

  • 的Android 1.5工作室或更高

嘗試在gradle這些更新,讓我們看看它是否工作:

  • com.google.firebase:火力數據庫:10.0.0
  • com.google.firebase:火力-AUTH:10.0.0
0

這種說法您的應用程序/的build.gradle的MUST go at the bottom文件:

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

像這樣:

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.android.support:appcompat-v7:24.2.1' 
    compile 'com.google.firebase:firebase-database:9.8.0' 
    compile 'com.google.firebase:firebase-auth:9.6.1' 
    compile 'com.firebaseui:firebase-ui-auth:1.0.0' 
    testCompile 'junit:junit:4.12' 
} 
apply plugin: 'com.google.gms.google-services' 

另外,正如@ anfuca的答案中所述,使用Firebase庫的一致版本非常重要。另外,請使用firebase-ui-auth的兼容版本,如Firebase UI page表中所列。還請注意,該頁面上的firebase-ui-authfirebase-auth具有運輸依賴性。您不需要在您的依賴項中包含firebase-auth

我的經驗是,下面的警告是無害的。我在和succussful AUTH動作之後看到它在我的日誌:

W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found 
4

我解決了這個問題,在火力地堡將在項目設置的SHA1指紋,因爲它是由谷歌需要登錄:

設置爲Android應用程序啓用Google登錄後,您需要在項目設置中爲每個應用程序添加SHA1指紋。

爲了得到這兩個發佈和調試證書按照Google APIs authentication guide

+0

我得到的稍微不同的錯誤信息是通過這個答案解決的,「E/GoogleProvider:Error with Google。10 null」。獲取SHA1哈希的一種便捷方式是使用名爲「signingReport」的gradle任務。 –

2

我有問題: Error logging in with Google. 10 null 和發現我錯了選擇使用谷歌play App Signing。然後解決方案是複製google play console中的SHA-1並將該值輸入到Firebase項目設置中。

相關問題