Using Google Firebase Remote Config without Google Play Services?
Asked Answered
E

3

8

Is it possible to use Firebase Remote Config without having Google Play Services installed (aosp) on the device?

I did follow this setup in my android project: (via https://firebase.google.com/docs/android/setup):

  1. added classpath 'com.google.gms:google-services:4.3.3' into main gradle file
  2. added implementation 'com.google.firebase:firebase-config:19.1.3' and 'apply plugin: 'com.google.gms.google-services'' into app gradle file

It does compile, but when I initially start the app fetchAndActivate does not succeed, because task results with after calling fetch():

MISSING_INSTANCEID_SERVICE (Failed to get Firebase Instance ID token for fetch)

  firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
        FirebaseRemoteConfigSettings.Builder configBuilder = new FirebaseRemoteConfigSettings.Builder();
        configBuilder.setMinimumFetchIntervalInSeconds(3600);


        firebaseRemoteConfig.setConfigSettingsAsync(configBuilder.build());
        HashMap<String, Object> defaults = new HashMap<>();
        defaults.put("variant", "basic");
        startActivity(new Intent(getApplicationContext(), CarLauncherBasic.class));

        firebaseRemoteConfig.setDefaultsAsync(defaults);
        firebaseRemoteConfig.fetchAndActivate()
                .addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
                    @Override
                    public void onComplete(@NonNull Task<Boolean> task) {
                        if (task.isSuccessful()) {
                            boolean updated = task.getResult();
                            Toast.makeText(MainActivity.this, "Fetch and activate succeeded",
                                    Toast.LENGTH_SHORT).show();

                        } else {
                            Toast.makeText(MainActivity.this, "Fetch failed",
                                    Toast.LENGTH_SHORT).show();
                        }
                        String variant = firebaseRemoteConfig.getString("variant");

//
                    }
                });

    }
Emissivity answered 18/3, 2020 at 14:8 Comment(0)
P
9

firebaser here

Firebase Remote Config no longer depends on Google Play Services, and can be used on any Android installation.

For an up to date list of what Firebase services work without Play services, see Dependencies of Firebase Android SDKs on Google Play services in the Firebase documentation.

Previous answer that was outdated:

Unfortunately Remote Config currently depends on having Google Play services installed on the device.

The dependency is indirect though, and transitive, which is why I (actually: we, as multiple folks went down this same rabbit hole) initially overlooked it.

The good news is that many Firebase services are moving to a newer service called Firebase Installation Service, which no longer depends on Google Play services. But there's no timeline for when Remote Config will no longer have that dependency.

Previous answer that was wrong 😞:

I asked around, and it seems that Remote Config does not depend on Google Play Services on the device. So you should be able to use it on an AOSP device.

However, a lot of use-cases for Remote Config depend on targeting users based on Analytics events and properties. And since Analytics is not part of Firebase's open-source SDKs, you won't be able to target users on AOSP with Analytics properties. The other targeting capabilities of Remote Config will work for everyone, but you'll only be able to target users based on Analytics events/properties if they are on a device with Google Play Services.

Pinkiepinkish answered 18/3, 2020 at 15:13 Comment(13)
But I suspect it would not be able to use the advanced targeting capabilities that require input from analytics. – Indoaryan
@Doug: I actually asked around and it seems Analytics also doesn't require Play Services. But Auth does (mostly for Google Sign-in iirc), so person-based targeting may be limited, but derived properties should still work. – Pinkiepinkish
Any reason why it's not open source, then? I was under the impression that Firebase SDKs that are not open source had a strong dependency on Play, which means they couldn't be compiled by everyone. github.com/firebase/firebase-android-sdk – Indoaryan
It's actually in the open source repo, just in a weird location (just config): github.com/firebase/firebase-android-sdk/tree/master/… – Pinkiepinkish
I meant analytics. If RC uses analytics data to target audiences, and analytics depends on Play, then it stands to reason that RC can't use any analytics targeting if Play isn't present. This is an important caveat to note. – Indoaryan
Ah, analytics has other non-open-source dependencies. And I think you're right, with some notes: if you make an AOSP and a Google Play version of your app, you indeed won't be able to target the AOSP users with analytics properties, but you will be able to target the Google Play users with those properties. In other words: it's not going to be ideal if you're looking to target users with analytics properties. – Pinkiepinkish
Thanks for verifying! – Indoaryan
@FrankvanPuffelen Hi thank you. I integrated firebase (with remote config) into my android project/app (on aosp) But when I'm running the app I receive: MISSING_INSTANCEID_SERVICE (Failed to get Firebase Instance ID token for fetch) as result after fetch. I googled a bit, and it tells me google play service must be installed? but it does not match with your assumption. – Emissivity
Hmmm... that one is documented as "Tokens can't be generated. Only devices with Google Play are supported", which seems correct for FCM tokens, since FCM is a Play-dependent service. But I'm nor sure why RC would require that, especially since I can't find any reference in the Github repo: github.com/firebase/firebase-android-sdk/… Can you see anywhere how InstanceId is being pulled in? – Pinkiepinkish
@FrankvanPuffelen I edited my answer and described my implementation of firebase remoteconfig (following your tutorials), the error does appear after first initial startup while fetchAndActivate. – Emissivity
thx for you updated answer! I'm looking forward that Remote config will moved too soon :) – Emissivity
@FrankvanPuffelen but why is it that the documentation here says it's not required nor recommended. firebase.google.com/docs/android/android-play-services – Tacnode
Hey @MihaeKheel. Good catch. As said in the answer and comments, the dependency on Play Services was being removed, and that has since been completed. I updated my answer to reflect and added a link to the new documentation page you mentioned. – Pinkiepinkish
W
6

The latest version of Firebase remote-config [19.2.0] seems to be working on devices with no Google PlayServices. I'm using it with Firebase analytics [17.4.4]. I could still see those PlayServices warnings in logcat but the feature seems to be working.

The remote-config [19.2.0] release notes at the url below states->"Migrated to use the Firebase installations service directly instead of using an indirect dependency via Firebase Instance IDs."
So, it's possible that this did the trick.
https://firebase.google.com/support/release-notes/android#remote-config_v19-2-0

Wellthoughtof answered 9/7, 2020 at 8:34 Comment(0)
G
0

This appears to have been introduced in newer versions of remote config. The last version that works for me on devices without Google Play Services is 19.1.0. Would be good to make sure that the Firebase folks are aware of this so it can be fixed in future versions.

I received this information from Firebase support: The Firebase Installation Service mentioned in the Stack Overflow post you've shared is not enough to remove the dependency on Play Services, so there are no current plans to address this.

Gmur answered 27/5, 2020 at 16:46 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.