firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
836 stars 430 forks source link

Support Firebase SDK on devices without Google Play Services #223

Open IanPhilips opened 6 years ago

IanPhilips commented 6 years ago

I'm using unity 2018.3.0b2 and the firebase sdk 5.3.1 to build on my Oculus Go.

At startup I get this in my debug: Firebase App initializing app com.eyeflite.wingvr

That's the last I see from my firebase debug output (no auth initiated or sign in attempt made). Then, I'm prompted with a system dialog that " {my app} won't run without play services which weren't supported by your device"

I hadn't seen this system prompt on 5.3.0 and the auth system was working fine. Any ideas about what's going on?

This is in my Awake() function:

  Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
    var dependencyStatus = task.Result;
        if (dependencyStatus == Firebase.DependencyStatus.Available) {
            // Create and hold a reference to your FirebaseApp, i.e.
            app = Firebase.FirebaseApp.DefaultInstance;
            auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
            Debug.Log("auth inited!");
            SignInAndGetToken();

    } else {
        UnityEngine.Debug.LogError(System.String.Format(
            "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
        // Firebase Unity SDK is not safe to use here.
    }
        });
stewartmiles commented 6 years ago

Almost all Firebase SDKs on Android compatible devices require Google Play Services. In particular the Unity SDK is built on top of the C++ and, transitively, the Android SDK which requires Google Play Services detailed here: https://firebase.google.com/docs/cpp/setup#requiring_google_play_services

IanPhilips commented 6 years ago

just reverted to sdk version 5.3.0 and no system dialog is displayed

IanPhilips commented 6 years ago

@stewartmiles I'm not sure what you mean, the sdk works as described on the getting started page as of 5.3.0 and as of 5.3.1 a system error dialog is displayed with the same code.

stewartmiles commented 6 years ago

@IanPhilips that's curious, what components in Firebase are you using? We did update the Android SDK library versions in the 5.3.1 SDK (see the *Dependencies.xml` files and the delta between them) so it's possible one of the libraries added a dependency upon Google Play Services that didn't exist before. If you're using anything other than Analytics, I would expect this to not work on any device that doesn't have the Play Store and Google Play Services.

IanPhilips commented 6 years ago

I'm only using Firebase.Auth

stewartmiles commented 6 years ago

Yep Auth definitely requires Google Play Services.

FWIW: https://developer.oculus.com/documentation/mobilesdk/latest/concepts/book-intro/ says...

No Google Play Services. Unlike the Samsung Galaxy devices that run Gear VR, Oculus Go does not ship with Google Play Services installed. You cannot rely on Google Play Services (e.g. Google Firebase, Google Cloud Messaging, etc) when running on Oculus Go.
IanPhilips commented 6 years ago

I saw that when I was looking around but I'm still confused why 5.3.0 would work and 5.3.1 wouldn't.

stewartmiles commented 6 years ago

Auth was upgraded in 5.3.1 and we've moved to require the most recent version of Google Play Services. If you side-load the latest Google Play Services it may (probably won't) work.

IanPhilips commented 6 years ago

Haha, okay thanks for your help. I wonder where the outdated Google Play Services is coming from...

jcyh0120 commented 5 years ago

Is there a guide if I want to develop for oculus go with firebase?

IanPhilips commented 5 years ago

@jcyh0120 you probably should not use firebase or if you have to, use the REST API

tairam commented 5 years ago

I need to use cloud storage with oculus go. Is it possible with RESTAPI?

alexames commented 5 years ago

@tairam Nope, the only officially supported way to use Firebase Storage is through the official APIs.

stewartmiles commented 5 years ago

@tairam it is possible to use the REST API instead of the SDK, it's work but it's possible.

yezzerfv commented 5 years ago

Are there plans to get Firebase working on devices without Google Play Services? While it may be possible to use the REST API with quite a lot of additional effort, the lack of built-in support means Oculus Go, Oculus Quest, and other HMDs running a flavour of Android (eg: HTC Focus?) means Firebase is a bad choice for developers. A shame, because it's my preferred solution on all the other platforms!

We're going to see more VR (and AR?) HMDs using Android be released, and to put up barriers for using Firebase on this emerging market seems a strange decision.

stewartmiles commented 5 years ago

@yezzerfv we're working on moving some components with the first one being Authentication on Android. This will allow the use of Auth, Function, Realtime Database, Storage and - eventually - Firestore, without Google Play Services.

Which products would you need to work?

Zhelyazko commented 5 years ago

What about Analytics / Crash reporting? I'm using them in a classic native (no Unity) Android app in an enterprise environment where Google Play Services is not available. Do you plan on migrating Analytics / Crash reporting / Performance monitoring w/o Play Services?

yahavt commented 5 years ago

@stewartmiles I think that for most of us in the VR world the priorities are (in this order):

  1. Auth
  2. Realtime Database
  3. Storage
  4. Functions / Firestore

I've been using your REST API for some time now to bypass this limit, but the downside is that the VR app and the firebase server data will be less secure.

stewartmiles commented 5 years ago

@Zhelyazko Google Analytics for Firebase doesn't require Google Play Services. I'm fairly sure that Crashlytics & Performance Monitoring currently have a dependency upon Instance ID which does require Google Play Services. We may change this dependency in future.

@yahavt as I mentioned we're moving Auth at the moment. So all of the products you've listed will be functional on devices without Google Play Services.

metallizard commented 5 years ago

Hi @stewartmiles

When / which version of firebase unity SDK that support Auth, firestore and storage to function without google services? I really would like to know because currently we're migrating to Oculus Quest from Cardboard and stuck with this issues :(

We were considering to Develop our own API using the REST API but it will take a while as well

stewartmiles commented 5 years ago

@metallizard the Android code is written to turn Firebase Auth into a thick client but it's going through review. We then need to alpha test it with Android devs before we can release it to the public with the C++ and Unity SDK updates to remove the check for Google Play Services being present if Firebase Auth is being used. Right now the timeline is at least a couple of months.

metallizard commented 5 years ago

So we can expect for Unity SDK at least a couple of months for now?

For now my apps need REST API then. Thank you for the info

denonzhu commented 5 years ago

MLkit barcode scanner can work without google play service? i had get the offline lib ,but it not work wihout goole play ~~~

vorporeal commented 5 years ago

@stewartmiles Any chance it would be possible to be part of an alpha testing group? I'm looking to use firebase for a prototype of an application for oculus quest; wouldn't mind rough edges or bugs or significant initial setup.

Alternatively, any guesses as to whether leveraging https://github.com/FirebaseExtended/auth-without-play-services to provide Firebase Auth would be sufficient to get the existing Unity SDK Realtime Database component working?

jyin96 commented 5 years ago

I would also be interested in opting into an alpha/beta of this. I'm looking to use Firebase for a quest application early-2020, and would like to start building out the infrastructure.

The components that I'm looking to use are Firebase Auth and Storage

stewartmiles commented 5 years ago

@vorporeal and @jyin96 I'll let the team know who are working on this.

yezzerfv commented 5 years ago

+1 for an alpha or beta, we're working on multiplatform collaboration software deploying to Quest among many other platforms so this would be super useful!

On Tue, 27 Aug 2019 at 21:39, Stewart Miles notifications@github.com wrote:

@vorporeal https://github.com/vorporeal and @jyin96 https://github.com/jyin96 I'll let the team know who are working on this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-unity/issues/223?email_source=notifications&email_token=AKYSF5GF4NMVNO7LOZ4FQI3QGWGGZA5CNFSM4F2Z2Y4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5JBLYY#issuecomment-525473251, or mute the thread https://github.com/notifications/unsubscribe-auth/AKYSF5HCHNYMZJKJQSTYO6TQGWGGZANCNFSM4F2Z2Y4A .

-- Iestyn Lloyd CTO

Check out our VR & AR collaboration tool, VISIONxR http://www.futurevisual.com/visionxr

iestyn@futurevisual.com www.futurevisual.com +44 (0)7595 499100

olivernash commented 5 years ago

+1 to an Alpha - already a Firebase customer and hoping to work on a Quest application asap using auth and Firestore

On Tue, Aug 27, 2019 at 4:46 PM yezzerfv notifications@github.com wrote:

+1 for an alpha or beta, we're working on multiplatform collaboration software deploying to Quest among many other platforms so this would be super useful!

On Tue, 27 Aug 2019 at 21:39, Stewart Miles notifications@github.com wrote:

@vorporeal https://github.com/vorporeal and @jyin96 https://github.com/jyin96 I'll let the team know who are working on this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/firebase/quickstart-unity/issues/223?email_source=notifications&email_token=AKYSF5GF4NMVNO7LOZ4FQI3QGWGGZA5CNFSM4F2Z2Y4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5JBLYY#issuecomment-525473251 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AKYSF5HCHNYMZJKJQSTYO6TQGWGGZANCNFSM4F2Z2Y4A

.

-- Iestyn Lloyd CTO

Check out our VR & AR collaboration tool, VISIONxR http://www.futurevisual.com/visionxr

iestyn@futurevisual.com www.futurevisual.com +44 (0)7595 499100

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-unity/issues/223?email_source=notifications&email_token=AAW64SSWRDTJBAVSRBZWPPDQGWHCRA5CNFSM4F2Z2Y4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5JCARI#issuecomment-525475909, or mute the thread https://github.com/notifications/unsubscribe-auth/AAW64SQCZLF7GEB54CLHUQLQGWHCRANCNFSM4F2Z2Y4A .

ampeixoto commented 5 years ago

@Zhelyazko Google Analytics for Firebase doesn't require Google Play Services. I'm fairly sure that Crashlytics & Performance Monitoring currently have a dependency upon Instance ID which does require Google Play Services. We may change this dependency in future.

@yahavt as I mentioned we're moving Auth at the moment. So all of the products you've listed will be functional on devices without Google Play Services.

@stewartmiles you said that Google Analytics for Firebase doesn't require Google Play Services, but if I log an event using the Firebase Analytics, I get the following logs in logcat: image

I setup Firebase Analytics as the tutorial: https://firebase.google.com/docs/analytics/android/start/

How should I setup my project so that I can user Firebase Analytics without Google Play Services (or with an outdated version)?

Is there any place where we can see the information of which Firebase components require Google Play Services?

yiliushenburke commented 5 years ago

@stewartmiles , thanks for clarifying. I'm getting what seems to be a similar error when running a project on the Oculus Quest that includes the Auth and Storage SDKs (version 6.4.0):

2019-09-17 23:31:39.531 14226-14250/? E/Unity: InitializationException:  Firebase modules failed to initialize: auth (missing dependency), storage (missing dependency)
      at Firebase.FirebaseApp.CreateAndTrack (Firebase.FirebaseApp+CreateDelegate createDelegate, Firebase.FirebaseApp existingProxy) [0x000e3] in <376fb5a5a3524225a54a2d810ebdc8a6>:0 
      at Firebase.FirebaseApp.Create () [0x00027] in <376fb5a5a3524225a54a2d810ebdc8a6>:0 
      at Firebase.FirebaseApp.get_DefaultInstance () [0x00017] in <376fb5a5a3524225a54a2d810ebdc8a6>:0 
      at Softspace.Apis.Firebase.FirebaseAuthClient.get_App () [0x00008] in <0290aec2e5d14994a3f043bd564f16aa>:0 
      at Softspace.Apis.Firebase.FirebaseAuthClient.get_Auth () [0x00008] in <0290aec2e5d14994a3f043bd564f16aa>:0 
      at Softspace.Apis.Firebase.FirebaseAuthClient.Awake () [0x00000] in <0290aec2e5d14994a3f043bd564f16aa>:0

This exception is thrown when the code tries to get the property FirebaseApp.DefaultInstance.

This is different from what @IanPhilips reported; there's no explicit reference to Google Play Services in my case. Is this still being caused by the same issue?

Regardless, we're also building for the Quest, and would love to be added to any alpha with a version of the SDK that doesn't need Google Play Services!

Thanks a bunch.

solarisn commented 5 years ago

Has anyone been able to get Firebase Analytics working on Oculus Go or Quest (no play services)? We have to make an analytics decision for a long-term project and would like to use Firebase. We're a VR/AR company so Play Services dependency is disqualifying.

For anyone else in a similar situation - I recommend checking out Segment to provide a REST API for you. The events can be forwarded to Firebase (and many other destinations) automatically. They don't actually have a first-party client SDK for Unity but there's a "community" integration here. It won't work as-is but I made a couple modifications and it's working great. If anyone is interested in my fixed version of that Segment Unity SDK, let me know and I'll create a public fork.

SkyeOfBreeze commented 5 years ago

I have had success recently with Firebase Analytics. As is, if the keys are setup properly (does not seem to auto update when changing package name via script, but might for you), it will schedule the data to be sent every hour, but within that time, the user could power down the headset or uninstall within that time and the events are potentially lost.

Had to modify it to send the data immediately on exit like iOS does, and this could also be used to customize the sending window

To make it reschedule, we called this code in onPause in an overridden Android activity. Maybe it would be best to have this functionality built into Firebase Analytics to send the data immediately but this seems pretty reliable for our uses without waiting for an update. We are not checking for existence of Google play services when using it, and we call this function on all devices. It only runs the service if the device does not have Google Play services.

//Java
private void MaybeRescheduleJobServiceImmediate() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
            ComponentName name = new ComponentName(getPackageName(),
                    "com.google.android.gms.measurement.AppMeasurementJobService");
            JobInfo job = getJob(name);
            if(job != null){
                jobScheduler.cancel(job.getId());
                JobInfo.Builder builder = new JobInfo.Builder(
                        job.getId(),
                        job.getService()
                );
                builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY); //this might need changed?
                builder.setMinimumLatency(1).setOverrideDeadline(1);
                builder.setExtras(job.getExtras());
                jobScheduler.schedule(builder.build());
            }
        }
    }

    @RequiresApi(21)
    @Nullable
    private JobInfo getJob(ComponentName name) {
        JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
        for(JobInfo info : jobScheduler.getAllPendingJobs()){
            if(info.getService().getClassName().equals(name.getClassName())){
                return info;
            }
        }
        return null;
    }

Edit: Also worth noting that Oculus will throw warnings/errors when trying to use Firebase Analytics in the project for any builds submitted (because it detects the use of Google Mobile Services). Not sure if Oculus plans on blocking builds at some point that trigger that warning, or what exactly needs to be manually pulled out to make the error go away without breaking anything

kostyabakay commented 5 years ago

So for today is it impossible to use Crashlytics on AR helmet without Google Play Services?

pahayah commented 4 years ago

So when can we expact the decoupling of Google Play for Unity so that Oculus Quest could work? We want to use mainly Auth and Realtime Database.

vorporeal commented 4 years ago

Any updates on alpha availability? Or, alternatively, any suggestions on how we could temporarily hack around the dependency to unblock development?

spobwoode commented 4 years ago

+1 for Firebase Quest support

yiliushenburke commented 4 years ago

Is this an issue the Firebase team is still working on?

stewartmiles commented 4 years ago

It's still being worked on, we have some services like Auth that are far harder to move than others so this is taking a while to get this out the door. We appreciate folks continuing to signal their need for this so feel free to keep on commenting which features you need to work on non-Google Play Services devices.

yiliushenburke commented 4 years ago

That’s great to hear, thank you Stewart!

olivernash commented 4 years ago

Thanks @stewartmiles

That's good to hear and +1 for Firebase Quest support.

Auth and Firestore would be great.

dayron9110 commented 4 years ago

@stewartmiles Hi, I am very worried because the Huawei personal contact me and they explained that new phones do not will have Play Services Installed(Old news). The app in the I work currently uses differents Google Services: play-services-ads,play-services-auth,firebase-messaging,firebase-analytics, Crashlytics, Google Sheets, Google Drive. Which of the previous libs Can I utilize without Play Services or Play Store installed on the new Huawei phones? Thanks for your help.

stewartmiles commented 4 years ago

@dayron9110 unfortunately, we still don't have a timeline in place to support devices without Google Play Services. Requirements for the Google Play Services APK / service / daemon (which isn't on these devices) are here. For G Suite APIs (Drive, Sheets etc.) you'll need to consult that team https://developers.google.com/gsuite/guides/android as I'm not sure whether their SDK logic is in the client library or in the Google Play Services APK.

3skild commented 4 years ago

Hope that this will be fixed. I have to change to something else because it is not running on Oculus Quest.

vrajasu commented 4 years ago

@stewartmiles : What is the current stand on Firebase Analytics without Google Play Services?

Tubyhes commented 4 years ago

Still very much looking forward to support for at least Auth and Firestore without Google Play Services!

yiliushenburke commented 4 years ago

We've had decent success using this 3rd party solution for Auth and Storage:

https://github.com/step-up-labs/firebase-authentication-dotnet https://github.com/step-up-labs/firebase-database-dotnet (we haven't tried this one) https://github.com/step-up-labs/firebase-storage-dotnet

bonchan commented 4 years ago

+1 for Firebase Quest support. Im using Real Time Database and Storage, do I need Auth too? any updates @stewartmiles ? thanks for your work!

dknchris commented 4 years ago

+1 For this. Firebase Auth, Database, Crashlytics needed without Play Services requirement. Please put this issue on priority as this will allow us to reach more users especially in China and also some privacy conscious users who do not use Google Apps on their devices.

katowulf commented 4 years ago

Hi folks, as noted several times in the thread, we hear the request and understand the need. Some Firebase services may never work without Play, some are taking a very long time to find solutions for. There are many blockers and complexities to this request, but it's definitely important to us.

Locking thread to prevent more "ETA please" requests (which will not help to prioritize this further and ultimately make it take longer as we spend more time answering them).