简体   繁体   中英

Android FCM + Nearby conflict

I need both Firebase Cloud Messaging and Nearby support in my app. The latest allowed Nearby version is 9.0.0 . So, I have to use following dependencies:

//Firebase
compile ‘com.google.firebase:firebase-core:9.0.0'
compile ‘com.google.firebase:firebase-messaging:9.0.0'
//Nearby
compile ‘com.google.android.gms:play-services-nearby::9.0.0’

It compiles successfully but when I try to get Firebase instance app crashes with IllegalAccessError:

java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:114)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

    Caused by: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/com.obolus.poc.customer-1/base.apk)
at com.google.firebase.iid.zzg.zzeC(Unknown Source)
at com.google.firebase.iid.zzg.<init>(Unknown Source)
at com.google.firebase.iid.zzg.<init>(Unknown Source)
at com.google.firebase.iid.zzd.zzb(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)

Using of different versions for these components causes compile error. Firebase 10.0.1 without Nearby works fine but I need both.

How can I solve this issue?

Thanks.

Solution

Perhaps it's a bug but for now to ensure that play-services plugin will check available versions correctly place line

apply plugin: 'com.google.gms.google-services'

at the bottom of your build.gradle file (below the dependencies block).

Check out https://firebase.google.com/docs/android/setup#add_the_sdk

I think you are wrong the latest nearby is v10 the same as Firebase use the following dependencies that are here under

com.google.android.gms:play-services-nearby:10.0.1
com.google.firebase:firebase-core:10.0.1
com.google.firebase:firebase-messaging:10.0.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM