【问题标题】:Simple Firebase Auth UI check and app crashes简单的 Firebase Auth UI 检查和应用程序崩溃
【发布时间】:2018-11-21 23:31:04
【问题描述】:

我遵循以下“如何添加 firebase ui auth”工作流程到我的应用程序,并且我有一个主要活动,如果用户登录与否,它只会更改文本视图。这就是代码的样子:

public class MainActivity extends AppCompatActivity {

    private static final int RC_SIGN_IN = 123;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        createSignInIntent();

    }
    public void createSignInIntent() {
        // [START auth_fui_create_intent]
        // Choose authentication providers
        List<AuthUI.IdpConfig> providers = Arrays.asList(
                new AuthUI.IdpConfig.EmailBuilder().build());

        // Create and launch sign-in intent
        startActivityForResult(
                AuthUI.getInstance()
                        .createSignInIntentBuilder()
                        .setAvailableProviders(providers)
                        .build(),
                RC_SIGN_IN);
        // [END auth_fui_create_intent]
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == RC_SIGN_IN) {
            IdpResponse response = IdpResponse.fromResultIntent(data);

            if (resultCode == RESULT_OK) {
                TextView tv = (TextView)findViewById(R.id.tv);
                tv.setText("Signed");
                FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
                // ...
            } else {

                // Sign in failed. If response is null the user canceled the
                // sign-in flow using the back button. Otherwise check
                // response.getError().getErrorCode() and handle the error.
                                    TextView tv = (TextView)findViewById(R.id.tv);
                tv.setText("Not Signed In");
            }
        }
    }
}

应用崩溃,Logcat 为空!

【问题讨论】:

  • 如果应用程序崩溃,会有一个堆栈跟踪。请在 logcat 上查找,并将其添加到您的问题中。

标签: android firebase firebase-authentication firebaseui


【解决方案1】:

当firebase和firebaseUI的库不兼容时,我已经看到了。

在清单文件中检查您的 firebaseUI 是否与正确的对应。 这是 firebaseUI 4.2.1 的示例

dependencies {
...
implementation 'com.firebaseui:firebase-ui:4.2.1'
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.5'
}

查看 FirebaseUI 兼容库的完整列表 检查此链接Firebase Compatibility

【讨论】:

    猜你喜欢
    • 2019-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多