gpt4 book ai didi

android - 使用 Google 登录时出现 Firebase 错误。 12501 空

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:26:48 25 4
gpt4 key购买 nike

不知道为什么会这样。不断收到此错误

Error logging in with Google. 12501 null

还有这个。

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

代码:

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);
}
}

Gradle :

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'
}

最佳答案

我解决了 Firebase 在项目设置中添加 SHA1 指纹的问题,因为它是 Google 登录所需要的:

To set up Google sign-in for your Android apps, you need to add the SHA1 fingerprint for each app on your Project Settings.

要获得发布和调试证书,请遵循 Google APIs authentication guide

关于android - 使用 Google 登录时出现 Firebase 错误。 12501 空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40771181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com