Firebase crashes with Android Instant apps

576 views Asked by At

I am trying to initialize Firebase(11.2.0) in an Android instant app using:

FirebaseApp.initializeApp(this);

But it throws following exception stating jobscheduler is not supported:

      E/FirebaseApp: Firebase API initialization failure.
  java.lang.reflect.InvocationTargetException
      at java.lang.reflect.Method.invoke(Native Method)
      at com.google.firebase.FirebaseApp.zza(Unknown Source)
      at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
      at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
      at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
      at com.hello.world.myapp.provider.MyApplication.onCreate(MyApplication.java:93)
      at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
      at android.app.ActivityThread.-wrap2(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
   Caused by: java.lang.SecurityException: Service: jobscheduler is not supported.
      at android.os.Parcel.readException(Parcel.java:1684)
      at android.os.Parcel.readException(Parcel.java:1637)
      at android.app.job.IJobScheduler$Stub$Proxy.cancel(IJobScheduler.java:202)
      at android.app.JobSchedulerImpl.cancel(JobSchedulerImpl.java:60)
      at com.google.android.gms.internal.zzcfj.zzazu(Unknown Source)
      at com.google.android.gms.internal.zzcfj.zzuh(Unknown Source)
      at com.google.android.gms.internal.zzcdm.initialize(Unknown Source)

I followed integration instructions given on android developer docs here.

2

There are 2 answers

2
Bob Snyder On

This may be a Firebase bug. The same stack trace appears in this Firebase Google Groups post. Ian Barber, a Firebase team member, replied to the post on August 2nd and said:

We have found an issue where Google Analytics for Firebase calls JobScheduler, which is unfortunately unsupported in instantapps. We have a fix internally, but unfortunately it has to go on to a fairly long release chain, so it will be several weeks before it hits SDK manager.

I recommend you contact Firebase support.

0
Prags On

With reference to Google issue tracker JobScheduler should be fixed now

The recommended approach would be to use the framework’s JobScheduler for API >= 21 since Instant Apps are only supported down to 21 anyways, and use Firebase JobDispatcher for the installed app for below 21.

example https://github.com/firebase/firebase-jobdispatcher-android
If any issue persists, please report at Google issue tracker they will re-open to examine.