3

Everytime at the 3th relaunch, my app gets stuck on a dark screen. I have no clue why, I have checked out the Facebook and Firebase docs, followed examples (github). Has anyone experienced this too?

Additional information:

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

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

MainActivity

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

}

Application:

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

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


}

Logcat (app specific) before last restart (there is no log on 3th restart/freeze)

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 background crash)

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
tomwassing
  • 925
  • 1
  • 10
  • 30

2 Answers2

0

Possibly this is an issue with the background Firebase Crash process calling the Facebook SDK in a way that the SDK didn't expect. You can guard that with a check for whether Firebase has initialised properly:

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

Try that, and see if it stop the freeze occurring.

Ian Barber
  • 19,765
  • 3
  • 58
  • 58
0

I have the same problem from firebase analytics version 9.0.2, I think it's a bug.

And I found this issue is on the analytics version 9.0.2, and I try to revert version to 9.0.0, it will be fine and no black screen.

But you are the auth lib 9.0.0, so I think it's different...

My solution like this:

compile 'com.google.firebase:firebase-analytics:9.0.0'
Takuma Lee
  • 1
  • 1
  • 1