20

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?

Gustavo Pagani
  • 6,583
  • 5
  • 40
  • 71
Kanj Narayan
  • 331
  • 1
  • 2
  • 8

4 Answers4

27

If you want to completely remove the firebase, you can achieve it by reversing the setup steps.

  1. Remove classpath 'com.google.gms:google-services:3.0.0' from your project gradle.
  2. Remove compile 'com.google.firebase:firebase-core:9.2.0' from your app build.gradle.
  3. Remove apply plugin: 'com.google.gms.google-services' from the bottom of your build.gradle.
  4. Remove FirebaseService code from your project.
  5. Remove google-services.json from your project.
  6. Remove google key from your Manifest.
  7. Remove google key from your resource value.
  8. Clean project.
  9. Build project.
  10. 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'
}
Community
  • 1
  • 1
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • I am using google analytics and maps APIs in my app. So I can't follow 1, 3, 5, 6 & 7 now. 2, 4, 8, 9, 10 have been taken care of. As far as remember, I had followed all these steps to remove firebase before I added google analytics & maps. – Kanj Narayan Jul 01 '16 at 13:27
  • Did you use the whole play service package, i.e **compile 'com.google.android.gms:play-services:9.2.0'**? – ישו אוהב אותך Jul 01 '16 at 13:32
  • I do not know groovy syntax. Where do I add this snippet? In project level gradle or app level? ..where in the file (If order matters as in "apply plugin" statements)? – Kanj Narayan Jul 04 '16 at 12:53
  • This works. I haven't completely understood this problem though. I have also noticed that there were a lot of "exclude-folder" and "order-entry" items with various firebase libs in app/app.iml before I added this configuration. I kept deleting those lines manually before each build. (Those lines kept coming back somehow.) After adding this configuration, I can see that fewer lines with firebase are being added in app.iml. I'll investigate more when I am on a faster computer. – Kanj Narayan Jul 04 '16 at 14:01
  • imho, because the play service include firebase core in itself. Could be for compatibility reason. Then could you mark this as answered? – ישו אוהב אותך Jul 04 '16 at 14:06
13

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.

Kanj Narayan
  • 331
  • 1
  • 2
  • 8
2

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'
Amir Dora.
  • 2,831
  • 4
  • 40
  • 61
0

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
  • 2
    Hi, please try to make your answer a bit easier to follow by using clear formatting. If it consists of a multi-step plan, just use a numbered list with at least one line per step – Ruben Helsloot Jun 30 '19 at 12:28