App initialization very slow: FirebaseApp initiali

2020-06-12 05:37发布

问题:

I know about this question but I don't think it helps me and the problem looks slightly different.

I'm doing this app where I need to implement AppsFlyer for tracking and I'm required to use only 2 components from Google Play Services:

com.google.android.gms:play-services-ads

com.google.android.gms:play-services-gcm

And I'm using the latest version of the Google Play Services, 9.0.2 that is.

The problem is that on the first app launch after installing the app, the app takes quite a bit of time to start. There's no log output and when the app starts doing something, the first line on the log is:

06-16 16:50:23.782 22368-22368/com.company.app I/FirebaseInitProvider: FirebaseApp initialization unsuccessful

I'm not using Firebase, how can I get rid of this? It really slows down the application initialization. Not a very good user experience...

EDIT:

I've added both libs, one at a time and I've realized that the GCM is the one causing the issue. When I add:

com.google.android.gms:play-services-gcm

I start getting the "FirebaseApp initialization unsuccessful" log and the app takes a while to start. Perhaps downgrading "fixes" the problem, but that's not a very good solution.

回答1:

I would suggest you to exclude the firebase group using gradle:

compile('com.google.android.gms:play-services-ads:9.0.2') {
    exclude group: 'com.google.firebase', module: 'firebase-common'
}

compile('com.google.android.gms:play-services-gcm:9.0.2') {
    exclude group: 'com.google.firebase', module: 'firebase-common'
}

Or, simply apply a global exclude configuration, like this:

configurations {
    all*.exclude group: 'com.google.firebase', module: 'firebase-common'
}

Hope it helps :)



回答2:

I had the same issue and not only I had to downgrade the services but also gradle version.

In my case I had (in app/build.gradle)

compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.google.android.gms:play-services-maps:9.0.2'
compile 'com.google.android.gms:play-services-gcm:9.0.2'

and (in build.gradle)

classpath 'com.android.tools.build:gradle:2.1.2'

After changing services back to 8.4.0 and gradle to 1.5.0 (Probably higher version is fine also but it was the one I had before upgrading to 2.1.2) everything is fine and FirebaseApp initialization is gone.

Maybe it's not the best solution but I couldn't find anything else.