gpt4 book ai didi

java - 第 3 次重新启动后,使用 Firebase 和 Facebook 身份验证的 LoginActivity 没有响应

转载 作者:太空狗 更新时间:2023-10-29 14:48:29 24 4
gpt4 key购买 nike

每次在第 3 次重新启动时,我的应用程序都会卡在黑屏上。我不知道为什么,我查看了 Facebook 和 Firebase 文档,并遵循示例 ( github )。有没有人也遇到过这种情况?

附加信息:

Facebook 库:com.facebook.android:facebook-android-sdk:4.12.0

Firebase 库:com.google.firebase:firebase-auth:9.0.0

主 Activity

public class MainActivity extends AppCompatActivity {

private static final String TAG = "MainActivity";
private Intent navigationIntent;
private Intent serviceIntent;

// FIREBASE
private FirebaseAuth firebaseAuth;
private FirebaseAuth.AuthStateListener firebaseAuthListener;

// FACEBOOK
private CallbackManager FBcallbackManager;

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

navigationIntent = new Intent(this, NavigationActivity.class);
serviceIntent = new Intent(this, BackgroundService.class);

// Initialize Firebase
firebaseAuth = FirebaseAuth.getInstance();

firebaseAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();

if (user != null) {
// User is signed in
// if so start next activty and close this one
Log.d(TAG, "User logged in");

startHomeActivity();

startActivity(navigationIntent);
finish();
} else {
Log.d(TAG, "User not logged in");
}

}
};

// Initialize Facebook Login button
FBcallbackManager = CallbackManager.Factory.create();
LoginButton loginButton = (LoginButton) findViewById(R.id.facebookButton);
loginButton.setReadPermissions("email", "public_profile");
loginButton.registerCallback(FBcallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
handleFacebookAccessToken(loginResult.getAccessToken());
}

@Override
public void onCancel() {

}

@Override
public void onError(FacebookException error) {
Log.d("Facebook Error", error.toString());
}
});


}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
FBcallbackManager.onActivityResult(requestCode, resultCode, data);
}

@Override
protected void onResume() {
super.onResume();
firebaseAuth.addAuthStateListener(firebaseAuthListener);
}

@Override
protected void onPause() {
super.onPause();
if (firebaseAuthListener != null) {
firebaseAuth.removeAuthStateListener(firebaseAuthListener);
}
}

private void handleFacebookAccessToken(AccessToken accessToken) {

final AuthCredential authCredential = FacebookAuthProvider.getCredential(accessToken.getToken());

firebaseAuth.signInWithCredential(authCredential).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {

if (task.isSuccessful()) {
Log.d(TAG, "Authentication successful");

startHomeActivity();

} else {
Log.d(TAG, "Authentication not successful");
Log.d(TAG, task.getException().getMessage());
}

}
});


}

private boolean isServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}

private void startHomeActivity() {

if (navigationIntent != null && serviceIntent != null) {

if (!isServiceRunning(BackgroundService.class)) {
startService(serviceIntent);
Log.d(TAG, "Service is no running. Starting service..");
} else {
Log.d(TAG, "Service is running. Not starting service..");
}

startActivity(navigationIntent);
finish();
}
}

}

应用:

public class ???????? extends Application {

@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
}


}

上次重启前的 Logcat(特定于应用程序)(第 3 次重启/卡住时没有日志)

05-24 16:53:19.547 16587-16618/my.package.app W/System.err: remove failed: ENOENT (No such file or directory) : /data/user/0/my.package.app/files/AppEventsLogger.persistedevents
05-24 16:53:19.557 16587-16609/my.package.app V/FA: Inactivity, disconnecting from AppMeasurementService
05-24 16:53:19.627 16587-16618/my.package.app I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:19.627 16587-16618/my.package.app I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:30.167 16587-16587/my.package.app D/ViewRootImpl: ViewPostImeInputStage processKey 0
05-24 16:53:30.247 16587-16587/my.package.app D/ViewRootImpl: ViewPostImeInputStage processKey 1
05-24 16:53:30.287 16587-16609/my.package.app V/FA: Activity paused, time: 455339818
05-24 16:53:30.807 16587-16587/my.package.app D/FirebaseApp: Notifying background state change listeners.a

Logcat(firebase 后台崩溃)

05-24 16:53:14.247 16940-16940/my.package.app:background_crash E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.crash.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/my.package.app-1/base.apk"],nativeLibraryDirectories=[/data/app/my.package.app-1/lib/arm64, /vendor/lib64, /system/lib64]]
05-24 16:53:14.247 16940-16968/my.package.app:background_crash W/System.err: remove failed: ENOENT (No such file or directory) : /data/user/0/my.package.app/files/AppEventsLogger.persistedevents
05-24 16:53:14.247 16940-16956/my.package.app:background_crash I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:14.247 16940-16956/my.package.app:background_crash I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-24 16:53:14.257 16940-16940/my.package.app:background_crash V/GoogleSignatureVerifier: com.google.android.gms signature not valid. Found:

// I have changed the key below for security reasons MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
05-24 16:53:14.267 16940-16940/my.package.app:background_crash W/ResourcesManager: getTopLevelResources: /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk / 1.0 running in my.package.app rsrc of package com.google.android.gms
05-24 16:53:14.267 16940-16940/my.package.app:background_crash D/ResourcesManager: For user 0 new overlays fetched Null
05-24 16:53:14.267 16940-16940/my.package.app:background_crash I/InjectionManager: Inside getClassLibPath caller
05-24 16:53:14.287 16940-16940/my.package.app:background_crash W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/arm64
05-24 16:53:14.297 16940-16940/my.package.app:background_crash W/ResourcesManager: getTopLevelResources: /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk / 1.0 running in my.package.app rsrc of package com.google.android.gms
05-24 16:53:14.297 16940-16940/my.package.app:background_crash D/ChimeraCfgMgr: Reading stored module config
05-24 16:53:14.317 16940-16940/my.package.app:background_crash I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:2
05-24 16:53:14.317 16940-16940/my.package.app:background_crash I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 2
05-24 16:53:14.317 16940-16940/my.package.app:background_crash W/ResourcesManager: getTopLevelResources: /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk / 1.0 running in my.package.app rsrc of package com.google.android.gms
05-24 16:53:14.327 16940-16940/my.package.app:background_crash I/InjectionManager: Inside getClassLibPath caller
05-24 16:53:14.327 16940-16940/my.package.app:background_crash W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000005/n/arm64-v8a
05-24 16:53:14.327 16940-16940/my.package.app:background_crash D/ChimeraFileApk: Primary ABI of requesting process is arm64-v8a
05-24 16:53:14.327 16940-16940/my.package.app:background_crash D/ChimeraFileApk: Classloading successful. Optimized code found.
05-24 16:53:14.337 16940-16940/my.package.app:background_crash I/FirebaseCrashReceiverServiceImpl: FirebaseCrashReceiverServiceImpl created by ClassLoader com.google.android.chimera.container.internal.DelegateLastPathClassLoader[DexPathList[[zip file "/data/user/0/com.google.android.gms/app_chimera/m/00000005/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk"],nativeLibraryDirectories=[/data/user/0/com.google.android.gms/app_chimera/m/00000005/n/arm64-v8a, /vendor/lib64, /system/lib64]]]
05-24 16:53:14.337 16940-16940/my.package.app:background_crash D/FirebaseCrashReceiverServiceImpl: onCreate
05-24 16:53:14.347 16940-16940/my.package.app:background_crash I/DynamiteModule: Considering local module com.google.android.gms.flags:0 and remote module com.google.android.gms.flags:1
05-24 16:53:14.347 16940-16940/my.package.app:background_crash I/DynamiteModule: Selected remote version of com.google.android.gms.flags, version >= 1
05-24 16:53:14.417 16940-16940/my.package.app:background_crash I/FirebaseCrashSenderServiceImpl: FirebaseCrashSenderServiceImpl created by ClassLoader com.google.android.chimera.container.internal.DelegateLastPathClassLoader[DexPathList[[zip file "/data/user/0/com.google.android.gms/app_chimera/m/00000005/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk"],nativeLibraryDirectories=[/data/user/0/com.google.android.gms/app_chimera/m/00000005/n/arm64-v8a, /vendor/lib64, /system/lib64]]]
05-24 16:53:14.417 16940-16940/my.package.app:background_crash D/FirebaseCrashSenderServiceImpl: onCreate

最佳答案

这可能是后台 Firebase 崩溃进程以 SDK 未预期的方式调用 Facebook SDK 的问题。您可以通过检查 Firebase 是否已正确初始化来保护它:

@Override
public void onCreate() {
super.onCreate();
if (!FirebaseApp.getApps(this).isEmpty()) {
FacebookSdk.sdkInitialize(getApplicationContext());
}
}

尝试一下,看看它是否能阻止卡住的发生。

关于java - 第 3 次重新启动后,使用 Firebase 和 Facebook 身份验证的 LoginActivity 没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37396811/

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