Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firebase.options.projectId is null on Android #446

Closed
calclavia opened this issue Sep 26, 2017 · 17 comments
Closed

firebase.options.projectId is null on Android #446

calclavia opened this issue Sep 26, 2017 · 17 comments
Assignees
Labels
help: needs-triage Issue needs additional investigation/triaging. platform: android plugin: app-core Firebase Apps / Core internals. Workflow: Waiting for User Response Blocked waiting for user response.

Comments

@calclavia
Copy link
Contributor

Issue

I noticed that on Android firebase.options.projectId is always null. On iOS the value is correct and gives me my project ID.

Environment

  1. Application Target Platform:
    Android
  1. Development Operating System:
    MacOS Sierra
  1. Build Tools:
    Android
  1. React Native version:
    0.43.4
  1. RNFirebase Version:
    3.0.0-alpha.5
  1. Firebase Module:
    Core
@Salakar
Copy link
Member

Salakar commented Sep 27, 2017

@calclavia can you debug on this line on android: https://github.com/invertase/react-native-firebase/blob/master/android/src/main/java/io/invertase/firebase/RNFirebaseModule.java#L144

See if appMapsList and then your project in that list has projectId correctly and it's not null. If it does then it's a JS issue, if it doesn't then it's a firebase android sdk issue, which would need flagging with firebase (firebase/firebase-ios-sdk#140 (comment) - have already flagged a similar issue on options before, not had a response though)

@Salakar Salakar self-assigned this Sep 27, 2017
@Salakar Salakar added platform: android plugin: app-core Firebase Apps / Core internals. labels Sep 27, 2017
@Salakar Salakar added this to the v3.0.0 milestone Sep 27, 2017
@Salakar Salakar added the Workflow: Waiting for User Response Blocked waiting for user response. label Sep 27, 2017
@Salakar
Copy link
Member

Salakar commented Oct 2, 2017

@calclavia any update on this?

@Salakar Salakar added the help: needs-triage Issue needs additional investigation/triaging. label Oct 2, 2017
@calclavia
Copy link
Contributor Author

calclavia commented Oct 3, 2017

@Salakar Here's the output when I print it out in Java. Seems like the output project name is null.

[{
databaseURL=https://PROJECT_NAME.firebaseio.com,
messagingSenderId=6848631879,
projectId=null,
name=[DEFAULT],
storageBucket=PROJECT_NAME.appspot.com,
appId=1:68486318790:android:07a4355cb2622ac,
apiKey=...
}]

@Salakar Salakar modified the milestones: v3.0.0 RC1, v3.0.0 RELEASE Oct 3, 2017
@Salakar
Copy link
Member

Salakar commented Oct 3, 2017

Just checked this on my end, for me it's giving me the projectId value - can you check your google services .json file and see if the projectId field is in there? project_info > project_id on my json file.

@calclavia
Copy link
Contributor Author

@Salakar Yes. In my Android google services I have the project_id set correctly.

@Salakar
Copy link
Member

Salakar commented Oct 3, 2017

@calclavia just to confirm is this for the default app? Or is this a new additional apps you're initialising via JS?

@calclavia
Copy link
Contributor Author

@Salakar default app

@Salakar
Copy link
Member

Salakar commented Oct 29, 2017

Have confirmed this is working on the latest release for both platforms, will close.

@Salakar Salakar closed this as completed Oct 29, 2017
@chrisbianca chrisbianca removed this from the v3.2.0 Release milestone Nov 9, 2017
@cawfree
Copy link

cawfree commented Dec 30, 2017

I've encountered this problem using "react-native-firebase": "^3.2.0". FirebaseOptions.getProjectId() cannot be null is thrown when I attempt to use:

firebase.firestore().collection('foo').add({bar : true}).

Strangely enough, all functionality associated with the standard firebase database works as expected.

After initializing using firebase.app(), the following credentials are successfully populated:
databaseURL, messagingSenderId, name, storageBucket, appId and apiKey.

As per good old StackOverflow, this can be resolved by using the following google-services version:

    classpath 'com.google.gms:google-services:3.1.0'

(I was using 3.0.0.)

@jSkrills
Copy link

jSkrills commented Feb 9, 2018

@Salakar I am still getting this error when trying to use dynamic links. I am using:

"react-native-firebase": "^3.2.4",
"react-native": "^0.51.0"

The only thing I did differently was reference version 9.8.0 instead of 11.6.0 (per the documentation). This was because I have recently detached to expoKit so I had a bunch of other play-services9.8.0 references in that file. So when I attempted to build in AndroidStudio I got a nice version mismatch error. Expos docs strongly suggest downgrading to meet them so I did to get around the error. All in all in the project/app/build.gradle file I changed the following lines from 11.6.0 to 9.8.0

// Firebase dependencies
compile "com.google.android.gms:play-services-base:9.8.0"
compile "com.google.firebase:firebase-core:9.8.0"
compile "com.google.firebase:firebase-invites:9.8.0"

I have a hard time believing that this is causing the No virtual method getProjectId() error but it's the only thing I can think of where I have strayed from the docs. Please let me know of anything else you might want to inquire about my environment. Any guidance, advice, or workarounds would be appreciated.

@jSkrills
Copy link

jSkrills commented Feb 9, 2018

@Salakar Nevermind, I just saw this link: #674

Now I know I need to use 11.6.0. Do you know if I have to roll all the play-services up to 11.6.0? I am concerned with updating a bunch of expo stuff.

@chrisbianca
Copy link
Contributor

@jakenolan I'm afraid to say that this will almost certainly be because you've downgraded the version to 9.8.0 - this version was released in October 2016, so any methods that have been added since then won't be available. I'd imagine that getProjectId is just the first of many problems that you'll run into.

@chrisbianca
Copy link
Contributor

@jakenolan Yes, all the play services need to run at the same version.

@jSkrills
Copy link

jSkrills commented Feb 9, 2018

@chrisbianca Thanks for the clarification. When I attempt to roll everything up to 11.6.0 and deploy my app via AndroidStudio the app dies before opening with this exception:

E/AndroidRuntime: FATAL EXCEPTION: Thread-9
Process: com.company.app, PID: 12345
java.lang.IncompatibleClassChangeError: Superclass com.google.android.gms.common.internal.zzj of com.google.android.gms.internal.zztx is an interface (declaration of 'com.google.android.gms.internal.zztx' appears in /data/app/com.company.app-1/split_lib_dependencies_apk.apk:classes51.dex)
at com.google.android.gms.ads.InterstitialAd.(Unknown Source)
at versioned.host.exp.exponent.modules.api.components.admob.RNAdMobInterstitialAdModule.(RNAdMobInterstitialAdModule.java:32)
at versioned.host.exp.exponent.modules.api.components.admob.RNAdMobPackage.createNativeModules(RNAdMobPackage.java:18)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1196)
at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1166)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1099)
at com.facebook.react.ReactInstanceManager.access$800(ReactInstanceManager.java:112)
at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:927)
at java.lang.Thread.run(Thread.java:761)

Any thoughts on this?

@chrisbianca
Copy link
Contributor

@jakenolan Looks like this is a problem with the react-native-admob - we do have admob functionality within react-native-firebase which you may be able to use instead?

@jSkrills
Copy link

jSkrills commented Feb 9, 2018

@chrisbianca I mean I am not "using" it for anything at all it was just something already in my project/app/build.gradle file. I attempted just removing this line:

compile 'com.google.android.gms:play-services-ads:11.6.0'

However I was left with this:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.company.app, PID: 12345
java.lang.NoClassDefFoundError: com.google.android.gms.common.zzj
at com.google.android.gms.common.zzo.isGooglePlayServicesAvailable(Unknown Source)
at com.google.android.gms.common.zze.isGooglePlayServicesAvailable(Unknown Source)
at com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(Unknown Source)
at host.exp.exponent.experience.BaseExperienceActivity.registerForNotifications(BaseExperienceActivity.java:225)
at host.exp.exponent.experience.ExperienceActivity.onResume(ExperienceActivity.java:192)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
at android.app.Activity.performResume(Activity.java:6783)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3406)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.IncompatibleClassChangeError: Superclass com.google.android.gms.internal.zzee of com.google.android.gms.common.internal.zzau is declared final (declaration of 'com.google.android.gms.common.internal.zzau' appears in /data/app/com.company.app-1/split_lib_dependencies_apk.apk:classes37.dex)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at com.facebook.internal.Utility.getMethodQuietly(Utility.java:795)
at com.facebook.internal.AttributionIdentifiers.getAndroidIdViaReflection(AttributionIdentifiers.java:92)
at com.facebook.internal.AttributionIdentifiers.getAndroidId(AttributionIdentifiers.java:75)
at com.facebook.internal.AttributionIdentifiers.getAttributionIdentifiers(AttributionIdentifiers.java:178)
at com.facebook.appevents.AppEventCollection.getSessionEventsState(AppEventCollection.java:85)
at com.facebook.appevents.AppEventCollection.addEvent(AppEventCollection.java:55)
at com.facebook.appevents.AppEventQueue$4.run(AppEventQueue.java:99)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

I did notice other exceptions above this fatal one that I hadn't noticed before but I am unsure if they are significant. They are as follows:

E/FA: Task exception on worker thread: java.lang.NoClassDefFoundError: com.google.android.gms.common.zzj: com.google.android.gms.internal.zzcjr.zzbaj(Unknown Source)

E/ExpoApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ComponentName android.content.Intent.getComponent()' on a null object reference

P.S. Thank you so much for your help. I apologize if I am coming off as a noob or overlooking simple things.

@chrisbianca
Copy link
Contributor

@jakenolan Not at all, RN can be somewhat frustrating and unfortunately in this case I'm not sure there's going to be a simple way to resolve it.

Taking a look at the Expo code, they have explicitly set the play services to v9.8.0 and are clearly relying internally on this specific version being available: https://github.com/expo/expo/blob/master/android/app/build.gradle

Without getting Expo to update their version, I'm not sure there's going to be way to get Expokit playing nicely without RNFirebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: needs-triage Issue needs additional investigation/triaging. platform: android plugin: app-core Firebase Apps / Core internals. Workflow: Waiting for User Response Blocked waiting for user response.
Projects
None yet
Development

No branches or pull requests

5 participants