invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.69k stars 2.21k forks source link

🔥Key httpResponseCode expected Integer but value was a java.lang.Double #2938

Closed charpeni closed 4 years ago

charpeni commented 4 years ago

Issue

2019-11-27 16:45:54.569 14076-14076/? W/Bundle: Key httpResponseCode expected Integer but value was a java.lang.Double.  The default value 0 was returned.
2019-11-27 16:45:54.570 14076-14076/? W/Bundle: Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
        at android.os.BaseBundle.getInt(BaseBundle.java:999)
        at android.os.BaseBundle.getInt(BaseBundle.java:981)
        at io.invertase.firebase.perf.UniversalFirebasePerfModule.lambda$stopHttpMetric$4(UniversalFirebasePerfModule.java:120)
        at io.invertase.firebase.perf.-$$Lambda$UniversalFirebasePerfModule$8oSWtKLEvWtKoK5hC2zPWKWFldM.call(Unknown Source:6)
        at com.google.android.gms.tasks.zzv.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

React Native's Bundle casts a Number to a Double, not an Int. See this for reference.

Possible fix

Double value = (httpMetricConfig.getDouble("httpResponseCode"));
httpMetric.setHttpResponseCode(value.intValue());

Project Files

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [x] my application is an AndroidX application? - [x] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [x] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy dependencies { classpath 'com.android.tools.build:gradle:3.5.2' classpath 'com.google.gms:google-services:4.3.3' classpath 'io.fabric.tools:gradle:1.31.2' classpath 'com.google.firebase:perf-plugin:1.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: 'io.fabric' apply plugin: "com.google.firebase.firebase-perf" [...] implementation 'com.segment.analytics.android:analytics:4.3.1' implementation 'com.google.firebase:firebase-core:16.0.1' ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 10.15 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 56.97 MB / 32.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node Yarn: 1.19.2 - /usr/local/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 23, 25, 26, 27, 28, 29 Build Tools: 27.0.3, 28.0.2, 28.0.3, 29.0.0, 29.0.2 System Images: android-23 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom Android NDK: 17.2.4988734 IDEs: Android Studio: 3.5 AI-191.8026.42.35.5977832 Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - 6.1.0 - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - N


Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

mikehardy commented 4 years ago

Normally the whole template is important, but the combination of a stack trace with non-obfuscated line numbers and a code version number definitely does the trick ;-) - do you already have a PR cooked up for personal use?

charpeni commented 4 years ago

Thanks for accepting my laziness! 😅

I do not have a PR ready for this, I just encountered that bug while doing the setup. I'm still not sure if my setup is working correctly though, Firebase console is still asking me to install the SDK.

I'm about to get off for Thanksgiving, but I'll be happy to cook up a PR for that next week if it's still waiting.

mikehardy commented 4 years ago

there was a doc PR recently that clarified this but in the console, it is "waiting" until it sees an analytics ping. But actually you can already start using it, the analytics ping is positive notice to google that you are setup, but absence of that positive doesn't mean you aren't actually set up, if that makes sense? You can get right to configuring other things and using it.

Enjoy the :turkey: :-)

stale[bot] commented 4 years ago

Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.