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

πŸ”₯ Analytics not working with flavors #4249

Closed Acetyld closed 4 years ago

Acetyld commented 4 years ago

Issue

So its not working somehow. Authentication, firestore is working fine. But.. analytics is giving "Failed to retrieve FireBase instance ID" The logEvents are not showing up in DebugView and every logEvent gives the Failed to retrieve firebase instance.. And i cant get the application verified in the firebase settings, it keeps asking to set SDK. Describe your issue here

afbeelding

Code i am using analytics().logEvent('test', { id: 3745092, item: 'mens grey t-shirt', description: ['round neck', 'long sleeved'], size: 'L', })

I tried:

Please help us out, we are stuck on this issue for so long. And its holding us back from rebuilding the app. And @mikehardy you stated you use flavors on a daily base. So how do you do it with the admob id's because we have different on each flavor. UPDATE: We use <meta-data tools:replace="android:value" android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="@string/google_app_id" /> and it seems to overwrite it!


Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "soundboard_app", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "androidcringe": "react-native run-android --variant \"cringeSoundboardDebug\" --appIdSuffix \"cringesoundboard\"", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@react-native-community/async-storage": "^1.12.0", "@react-native-community/eslint-plugin": "^1.1.0", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.9.6", "@react-native-firebase/analytics": "^7.6.2", "@react-native-firebase/app": "^8.4.2", "@react-native-firebase/auth": "^9.2.2", "@react-native-firebase/firestore": "^7.8.1", "@react-navigation/drawer": "^5.9.0", "@react-navigation/native": "^5.7.3", "@react-navigation/stack": "^5.9.0", "@reduxjs/toolkit": "^1.4.0", "axios": "^0.20.0", "eslint-config-prettier": "^6.11.0", "i18next": "^19.7.0", "moment": "^2.27.0", "patch-package": "^6.2.2", "prop-types": "^15.7.2", "react": "16.13.1", "react-hook-form": "^6.8.1", "react-i18next": "^11.7.2", "react-native": "0.63.2", "react-native-bootsplash": "^2.2.5", "react-native-device-info": "^6.0.2", "react-native-error-boundary": "^1.1.2", "react-native-fast-toast": "^1.0.6", "react-native-gesture-handler": "^1.8.0", "react-native-iap": "^4.5.3", "react-native-keyboard-aware-scroll-view": "^0.9.2", "react-native-reanimated": "^1.13.0", "react-native-safe-area-context": "^3.1.7", "react-native-screens": "^2.10.1", "react-native-sound": "^0.11.0", "react-native-svg": "^12.1.0", "react-native-swipe-gestures": "^1.0.5", "react-native-tiny-toast": "^1.0.7", "react-native-webview": "^10.8.3", "react-redux": "^7.2.1", "recyclerlistview": "^3.0.0", "redux": "^4.0.5", "rn-fetch-blob": "^0.12.0" }, "devDependencies": { "@babel/core": "^7.8.4", "@babel/runtime": "^7.8.4", "@react-native-community/eslint-config": "^1.1.0", "@types/node": "^14.10.1", "babel-jest": "^25.1.0", "eslint": "^6.5.1", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.59.0", "react-test-renderer": "16.13.1" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

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? #### 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`: ``` buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 16 compileSdkVersion = 29 targetSdkVersion = 29 // Put here other AndroidX dependencies } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.6.3") classpath 'com.google.gms:google-services:4.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } ``` #### `android/app/build.gradle`: ``` apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' // <- Add this line ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: Windows 10 10.0.19041 CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor Memory: 13.95 GB / 31.94 GB Binaries: Node: 14.5.0 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 23, 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.0 System Images: android-28 | Google Play Intel x86 Atom Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Version 4.0.0.0 AI-193.6911.18.40.6514223 Visual Studio: Not Found Languages: Java: Not Found Python: Not Found npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2 react-native-windows: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **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:** - `newest` - **`Firebase` module(s) you're using that has the issue:** - `Analytics` - **Are you using `TypeScript`?** - `N`


Acetyld commented 4 years ago

afbeelding Update also not working with make-demo-v6.

Logcat log:

2020-09-11 22:48:23.790 15864-15903/com.rnfbdemo W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2020-09-11 22:48:23.842 15864-15901/com.rnfbdemo V/FA: Deferring to Google Analytics for Firebase for event data collection. https://goo.gl/J1sWQy
2020-09-11 22:48:23.933 15864-15907/com.rnfbdemo W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2020-09-11 22:48:24.045 15864-15907/com.rnfbdemo I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2020-09-11 22:48:24.321 15864-15918/com.rnfbdemo I/FA: To enable faster debug mode event logging run:
      adb shell setprop debug.firebase.analytics.app com.rnfbdemo
2020-09-11 22:48:24.574 15864-15864/com.rnfbdemo I/FirebaseCrashlytics: Initializing Crashlytics 17.1.1
2020-09-11 22:48:24.648 15864-15943/com.rnfbdemo D/FirebaseRemoteConfig: Persisted config file was not found.
    java.io.FileNotFoundException: /data/user/0/com.rnfbdemo/files/persisted_config (No such file or directory)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(FileInputStream.java:231)
        at java.io.FileInputStream.<init>(FileInputStream.java:165)
        at android.app.ContextImpl.openFileInput(ContextImpl.java:560)
        at android.content.ContextWrapper.openFileInput(ContextWrapper.java:202)
        at com.google.firebase.remoteconfig.internal.LegacyConfigsHandler.readPersistedConfig(LegacyConfigsHandler.java:339)
        at com.google.firebase.remoteconfig.internal.LegacyConfigsHandler.getConvertedLegacyConfigs(LegacyConfigsHandler.java:196)
        at com.google.firebase.remoteconfig.internal.LegacyConfigsHandler.saveLegacyConfigsIfNecessary(LegacyConfigsHandler.java:151)
        at com.google.firebase.remoteconfig.RemoteConfigComponent$$Lambda$4.call(Unknown Source:2)
        at com.google.android.gms.tasks.zzz.run(com.google.android.gms:play-services-tasks@@17.0.2:2)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
2020-09-11 22:48:24.667 15864-15933/com.rnfbdemo I/FirebaseCrashlytics: Crashlytics NDK initialization successful
2020-09-11 22:48:24.693 15864-15864/com.rnfbdemo I/FirebaseInitProvider: FirebaseApp initialization successful
2020-09-11 22:48:24.696 15864-15864/com.rnfbdemo D/ReactNativeFirebaseApp: received application context.
2020-09-11 22:48:27.061 15864-15978/com.rnfbdemo W/FIAM.Headless: Service fetch error: PERMISSION_DENIED: Firebase In-App Messaging API has not been used in project 81004061541 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebaseinappmessaging.googleapis.com/overview?project=81004061541 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
2020-09-11 22:48:33.551 15864-16004/com.rnfbdemo W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class io.invertase.firebase.admob.ReactNativeFirebaseAdMobBannerAdViewManager
mikehardy commented 4 years ago

I don't see anything in the log that indicates a failure, those look normal to me. Have you turned on analytics debugging? https://firebase.google.com/docs/analytics/debugview

May help

Acetyld commented 4 years ago

afbeelding Yes i did :(...

I tried it so many times, on off, triple checked package name. Nothing seems to work keep getting Failed to retrieve Firebase Instance Id @mikehardy

UPDATE: It also happens on a real device. Keep getting "Failed to retrieve Firebase Instance Id" when i open app (openscreen evetns etc..) and when i send a event my self to analytics.

UPDATE 2: 11-9-2020 23:33 afbeelding Also this is stuck. Tried with release build, real device etc.. never got a connection ..

UPDATE 3 12-9-2020 09:44 Totally stuck right now :(

UPDATE 4 12-9-2020 13:26 Only problem right now is logEvent. I someone has time please let us know, we are really focusing on getting the app done this week .

UPDATE 5 12-9-2020 13:49 Atm we are highly thinking of overswitching to: https://www.npmjs.com/package/react-native-admob-native-ads Analytics can also be done using a API and there are enough other push messages solutions.

We would just love this to work tho..


And if you want, please check my original post with the sub questions for your specific @mikehardy And i am 100% up for a remote session or discord call (payed) if thats a possibily.

Acetyld commented 4 years ago

WE FIXED IT!

So yhea.. after making a new project with flavours from sratch first i didint work then we switched to expo firebase also same problem. Then we switched back to rnfirebase and we found the problem..

<meta-data
      tools:replace="android:value"
      android:name="com.google.android.gms.ads.APPLICATION_ID"
      android:value="@string/google_app_id" />

This line in the android manifest was causing it and to be specific: @string/google_app_id this part was the problem Because google adds its own string called : "google_app_id" so yhea we changed that to google_ad_id (for admob as it was ment) and BOOM! It works, firebase connects and analytics works <3 Only problem remaning is crashlytics right now.

mikehardy commented 4 years ago

My goodness - that is...so obscure. I'm not sure I would have ever found that

mikehardy commented 4 years ago

by the way - worth mentioning that comment edits do not generate notifications, I never saw those! sorry