App initialization very slow: FirebaseApp initialization unsuccessful - android

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.

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 :)

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.

Related

Program type already present androidx.exifinterface.R

I recently added implementation 'com.google.android.play:core:1.6.4' as a dependency in my android project and now Intellij is complaining that Program type already present: androidx.exifinterface.R. What does this mean and how do I fix this?
Note: this is meant to be a Q&A question. I've already found a solution and I want to share with others.
I recently ran into an issue where android studio would complain that Program type already present: androidx.exifinterface.R. This happened after adding the implementation 'com.google.android.play:core:1.6.4' dependency. I had stumbled on this before with androidx.asynclayoutinflater.R. I've found the that adding something like the following to your module level gradle file will fix it:
configurations.all {
// This is from a previous, similar issue
exclude group: "androidx.asynclayoutinflater", module: "asynclayoutinflater"
// This is the LOC that fixed the issue in this post
exclude group: "androidx.exifinterface", module: "exifinterface"
}
The pattern seems to be:
if there's a complaint about androidx.MODULE_X.R already being present
then add
exclude group: "androidx.MODULE_X", module: "MODULE_X"
to configurations.all in module level gradle file
This worked for both asynclayoutinflater and now exifinterface. I don't know if the pattern scales but so far it has worked. My understanding of the underlying issue is that two dependencies in the module dependency graph (eg com.google.android.play:core) explicitly include the problematic module (eg exifinterface) and so we need to exlude one of those explicit dependencies. My understanding might be wrong.

Cloud Firestore with gRPC build error

I’m working on an android application, which have to use gRPC and Firestore. However, when I added both one of module from ‘io.grpc’ group dependency (e.g. io.grpc:grpc-okhttp:1.7.0) and firestore dependency (com.google.firebase:firebase-firestore:11.4.2) in the build gradle config, I got a build error “Unable to merge dex”. After with ‘stacktrace’ build option, I saw that the problem is
Multiple dex files define Lio/grpc/internal/OobChannel$5;
It could happen if firestore uses grpc-core module, but there is no one similar in tree dependencies, which I got using [androidDependencies] gradle task. I tried to exclude io.grpc like this:
implementation ('com.google.firebase:firebase-firestore:11.4.2') {
exclude group: 'io.grpc'
}
but there was the same error. Then I thought what if I exclude all ‘io.grpc.’ transitive dependencies from grpc module dependencies with adding grpc-core for internal classes. In this way, I wrote ugly dependencies just for test
implementation 'com.google.firebase:firebase-firestore:11.4.2'
implementation('io.grpc:grpc-okhttp:1.7.0') {
exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-protobuf-lite:1.7.0') {
exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-stub:1.7.0') {
exclude group: 'io.grpc'
}
implementation 'io.grpc:grpc-core:1.7.0'
I was surprised when it successfully compiled, but after launch app, it crashed with java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev)
Caused by: java.lang.NoSuchMethodError: No static method zzcyc()Lio/grpc/ManagedChannelProvider; in class Lio/grpc/ManagedChannelProvider; or its super classes (declaration of 'io.grpc.ManagedChannelProvider' appears in /data/app/com.zipr.test-2/split_lib_dependencies_apk.apk)
I use gradle 3.0.0-rc1 with enabling multidex support. I deleted .gradle, build directories, cleaned rebuilt project, but I still have build error. What can I do to resolve this problem?
Due to a variety of factors that constrain the way we build Android SDKs at Google, Firestore proguards a copy of gRPC within itself. Unfortunately this is leaky and you're running into the fallout: the 11.4.2 Firestore SDK is incompatible with any external gRPC :-(.
This is essentially our top issue for the Firestore Android SDK and I'm sorry you've run into it.

Google play services raising the version of support-v4 (to 24.0.0)

In my project I'm compiling against sdk-version 23 and using the compat/support libraries version 23.2.0.
Now I'm trying to update the play-services-version from 9.2.1 to 10.2.0
compile 'com.google.android.gms:play-services-base:10.2.0'
But making this change ads the com.android.support:support-v4:24.0.0 library to my project making my project to crash due with strange not found errors in the compat libraries like explained in this question.
How can I avoid that? should I skip the play-services update? can I avoid them to raise the version of the support-v4 lib?
Maybe it could work with something like this:
compile('com.google.android.gms:play-services-base:10.2.0') {
exclude group: 'com.android.support'
}
or if this does not work then maybe:
compile('com.google.android.gms:play-services-base:10.2.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
Or maybe you don't need the whole base play services and only specific packages as defined here

Remove firebase analytics from android app completely

I added firebase analytics in my app just to try it out. I followed the steps in official guidelines.
Now I have decided against it. I have undone whatever I had done to add it.
(Removed entries from project level and app level build.gradle; removed all usages from source code.)
But I am still getting logs like this when my app runs:
I/FirebaseInitProvider: FirebaseApp initialization successful
This leads me to believe that I haven't removed it completely. This is really a matter of concern for me now because my app has exceeded method count limit and I have had to enable multidex.
How can I completely remove firebase from my app?
If you want to completely remove the firebase, you can achieve it by reversing the setup steps.
Remove classpath 'com.google.gms:google-services:3.0.0' from your project gradle.
Remove compile 'com.google.firebase:firebase-core:9.2.0' from your app build.gradle.
Remove apply plugin: 'com.google.gms.google-services' from the bottom of your build.gradle.
Remove FirebaseService code from your project.
Remove google-services.json from your project.
Remove google key from your Manifest.
Remove google key from your resource value.
Clean project.
Build project.
Remove installed app from test device, then install it again.
-- UPDATE --
From https://stackoverflow.com/a/37945280/4758255 :
I would suggest you to exclude the firebase group using gradle in app module build.gradle, you can add this in dependency:
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 (Remember that this should be outside any groovy function), like this :
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-common'
}
Adding
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-core'
all*.exclude group: 'com.google.firebase', module: 'firebase-iid'
}
removes all lines from app/app.iml containing firebase (and they do not get added automatically again) and removes all firebase libraries from generated code and intermediate output as well.
Compared to the previous answer this knocks off another 87,000 bytes from apk size.
Though I still do not understand why I should have to ADD more code to undo adding something. It's probably a bug in the build system.
#isnotmenow: Thanks a lot for pointing me in this direction.
I had the same issue, i removed google_services.json file. Removed firebase dependencies and most importantly in build.gradle (Project: GrowBuds) remove the following line
apply plugin: 'com.google.gms.google-services'
i was also facing this issue and after too much effort i have find a legal solution
1)Change the package name
the method of changing the pacakage name
1) convert your studio from project level to android level
2)right click on android level and click on Compact middle pacakage
3)change the middle name of packge
4)again like 3rd step change the last name of package
5)change the package name in gradle file
2)go to firebasel console add project manullay
add your new pacakge name
add your sha1 key and continue
3)synchronise your project yahoo you have done \
List item

Duplicate class contained in the libs of android project

When I was trying to use Android Studio to debug my project, I got the following error,
Class com.google.ads.AdRequest.Gender has already been added to output. Please remove duplicate copies.
The cause seems to be that the google play services lib and another lib used by my project both contain the com.google.ads.AdRequest.Gender class, and I don't think I can remove it from either one.
Does anyone know how to fix this problem?
Thanks a lot.
I tried the following statement in build.gradle in order to exclude the duplicated classes in the google play services lib, but it still does not solve the problem.
compile ('com.google.android.gms:play-services:4.1.32') {
exclude group: 'com.google.ads'
}
You can try using Gradle's exclude mechanism when setting up the DatawindAdsSdk-2.0 dependency. There are docs available, but it will probably look something like this:
dependencies {
compile files('libs/datawindAdsSdk-2.0.jar') {
exclude group: 'com.google.ads'
}
}
experiment with that and see if you can get it working.
But I came to this post via google and I read this post has the same problem as me. I solved it excluding the group and the whole library. In my case the problem was with an animatorListener.
compile ('com.rengwuxian.materialedittext:library:1.8.2'){
exclude group: 'com.nineoldandroids', module: 'library'
}
This is my post duplicate library gradle animatorlistener duplicate

Categories

Resources