Closed Hemistone closed 3 years ago
Unrelated, but I can't help noticing:
Don't use this: "react-native-splash-screen": "^3.2.0" - https://github.com/crazycodeboy/react-native-splash-screen/issues/289#issuecomment-502406454 - save yourself future pain
Also your gradle plugins are out of date, not the cause of this problem though
I'd be curious to see more of the adb logcat when this happens. I'm not sure of your specific logic but it seems fine as far as it goes - it's not really a minimal App.js I can just reproduce. I wonder what would happen if you replaced it with the verbatim contents of the guide https://rnfirebase.io/remote-config/usage#fetch--activate
@mikehardy Thank you for your reply. I will first change the "react-native-splash-screen" library and also update gradle plugins too.
After doing all of these, I will test again and if it still not works I will make comment with adb logcats.
However for in case of logcat, there was no special logs other than
[Error: [remoteConfig/failure] fetch() operation cannot be completed successfully.]
@mikehardy I finished upgrading gradle plugin and also changed splash screen library to react-native-bootsplash
.
Remote-config worked well on iOS simulator and iOS real device, but still returned same error on android simulator and real device. It seems to have problem in Android related area.
adb logcat
gave log gave me same error again as before.04-26 16:51:38.530 18712 20503 E ReactNativeJS: { [Error: [remoteConfig/failure] fetch() operation cannot be completed successfully.]
04-26 16:51:38.530 18712 20503 E ReactNativeJS: line: 25433,
04-26 16:51:38.530 18712 20503 E ReactNativeJS: column: 28,
04-26 16:51:38.530 18712 20503 E ReactNativeJS: sourceURL: 'http://localhost:8081/index.bundle?platform=android&dev=true&minify=false' }
node_modules/@react-native-firebase/remote-config/lib/index.js
fetch(expirationDurationSeconds) {
if (!isUndefined(expirationDurationSeconds) && !isNumber(expirationDurationSeconds)) {
throw new Error(
"firebase.remoteConfig().fetch(): 'expirationDurationSeconds' must be a number value.",
);
}
return this._promiseWithConstants(
this.native.fetch(expirationDurationSeconds !== undefined ? expirationDurationSeconds : -1),
);
}
Can you find any clue about this error with my experience?
@mikehardy Hello, any new updates?
Sorry I haven't had time to try locally, all I know for sure is that our e2e tests fetch remote config on Android and they work. Unfortunately I've had higher priority work to this point, I'm not sure when I'll have time to focus on this
@mikehardy Can you tell what js environment and android environment is used in e2e test? I will also try it in a new project.
You can check the runs and verify everything directly:
@mikehardy Thank you I will check on it. May you still open my issue until it gets fixed by myself or your additional comment with local reproducing?
Sure - and obviously any time new information comes in that implicates some error in the module - even if it's closed already - we'll reopen no problem.
Faced with the same issue, interesting note -> this error occurs when device lost internet connection.
@dima-mamaev very little of firebase will work correctly offline unless you handle errors like this and have any databases configured correctly to work in offline mode etc. Definitely has to be tested. That's 100% expected
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.
Started using Remote Config for A/B-testing a couple of weeks ago and I'm seeing thousands of reports of this error in Crashlytics, roughly estimated to 10% of active users on both iOS and Android. Currently on v12.0.0, so upgrading to 12.1.0 might help. Just wanted to keep this from becoming more stale since it seems like a problem?
I think it's less a problem and more either an API issue (remote config throttles really aggressively) or an offline issue, but it is not fully understood yet so it's staying open. All I know is in my work projects and our e2e tests here it meets API expectations. What's the gap between that and reports here? Unknown
Recently me and our team gave a second try of remote-config package with new CRNA(typescript, bare RN project), and it still did not work on android, throwing same error as before(works well on iOS).
react: 17.0.1
react-native: 0.64.1
@react-native-firebase/app, remote-config: 12.1.0
(other environments are same as the initial Issue comment)
I would agree that it is an Issue with remote-config API, but it is bit weird since iOS really works well. Something is going on the native android package sideπ I don't know why your e2e tests have no problem, but it is a reproduce-able Issue in my personal experience.
Hi got the same error when I updated rnfb to 12.2.0v . On iOS it looks good and working ok but on Android, I encounter this issue. I see some issue also when I set to default with JSON data but it produces this value in Android
vs in iOS it has the correct a output.
here is my setup
"react": "17.0.1",
"react-native": "0.64.2",
"@react-native-firebase/app": "^12.2.0",
"@react-native-firebase/remote-config": "^12.2.0",
is there any changes in Android that affects the result?
-----UPDATE---- It looks like it works OK if publish the app in release version and not in debug version. But still I need the debug env :(. Weird bug!
There was nothing in 12.2 that should have bearing on this
I started having this problem with a release version of android. After going back and forth I decided to look at the API key since this problem was jus happening on the release version.
After going to https://console.cloud.google.com/apis/credentials and checking the key on google-services.json and GoogleService-Info.plist
"api_key": [
{
"current_key": "XXXXXXXX"
}
]
<key>API_KEY</key>
<string>XXXXXXXX</string>
Against the same key in the credentials page, it turned out my key was only available to a handful of services but not remote config. Enabling the key to be used for remote config fixed the issue.
@Esbruiz THANK YOU SO MUCH!!! I've never thought about that even @mikehardy gave hint to me to check my API levels, I was really dumbπ©. Maybe I should make a new PR with updates on README to check your API keys to be enabled firebase services for dumb people like meπ€£
I'm still facing this issue on Android, on iOS it works fine, but on Android it's failing and only message that I can extract from error is [Error: [remoteConfig/failure] fetch() operation cannot be completed successfully.]
I've checked api key restrictions on api credentials page and it's unrestricted, and it's auto created by Firebase console, so this issue shouldn't be related with that.
Firebase info:
"@react-native-firebase/analytics": "^15.1.1",
"@react-native-firebase/app": "^15.1.1",
"@react-native-firebase/crashlytics": "^15.1.1",
"@react-native-firebase/remote-config": "^15.1.1",
React native: 0.68.2 Android version: 7.0
Any help would be appreciated.
Issue
First of all, thank you for making and maintaining this package. πππ
I was using well with analytics, crashlytics, messaging, and now trying to use remote-config as well. However, remote-config keep returns error message as this in both android and ios real devices.
These are my source codes.
App.tsx
The useEffect hook is right under mother component
App
. I took out several config functions intracker.ts
, andTracker.firebaseRemoteConfig()
function looks like thistracker.ts
As result, every time I run the script, it fails remoteConfig().blablas and catches
[Error: [remoteConfig/failure] fetch() operation cannot be completed successfully.]
.Is there any problem with my remoteConfig fetching logic? or is there any problem in the library?
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "drcha", "version": "1.3.1", "private": true, "scripts": { "android": "react-native run-android", "android:clean": "cd android && ENVFILE=environments/.env.debug ./gradlew clean", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "cph": "appcenter codepush deployment history", "cprc": "appcenter codepush release-react", "list:android:stage": "yarn cph -a autopedia/dr-cha-android Staging", "list:ios:stage": "yarn cph -a autopedia/dr-cha-ios Staging", "list:android:prod": "yarn cph -a autopedia/dr-cha-android Production", "list:ios:prod": "yarn cph -a autopedia/dr-cha-ios Production", "publish:android:stage": "yarn cprc -a autopedia/dr-cha-android -t '1.3' ", "publish:ios:stage": "yarn cprc -a autopedia/dr-cha-ios -t '1.3' ", "publish:android:mandatory": "yarn cprc -a autopedia/dr-cha-android -m -t '1.3' ", "publish:ios:mandatory": "yarn cprc -a autopedia/dr-cha-ios -m -t '1.3' ", "codegen": "graphql-codegen --config codegen.yml" }, "dependencies": { "@apollo/client": "^3.1.4", "@invertase/react-native-apple-authentication": "^2.0.2", "@react-native-community/async-storage": "^1.12.0", "@react-native-community/cameraroll": "^4.0.0", "@react-native-community/cli": "^4.12.0", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/google-signin": "^4.0.3", "@react-native-community/hooks": "^2.6.0", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.9.6", "@react-native-community/push-notification-ios": "^1.5.0", "@react-native-firebase/analytics": "^11.2.0", "@react-native-firebase/app": "^11.2.0", "@react-native-firebase/crashlytics": "^11.2.0", "@react-native-firebase/messaging": "^11.2.0", "@react-native-firebase/remote-config": "^11.2.0", "@react-native-seoul/kakao-login": "^2.10.1", "@react-navigation/bottom-tabs": "^5.8.0", "@react-navigation/material-top-tabs": "^5.2.16", "@react-navigation/native": "^5.7.3", "@react-navigation/stack": "^5.9.0", "@reduxjs/toolkit": "^1.4.0", "apollo3-cache-persist": "^0.6.0", "axios": "^0.20.0", "cuid": "^2.1.8", "graphql": "^15.3.0", "graphql-tag": "^2.11.0", "haversine-distance": "^1.2.1", "josa": "^3.0.1", "lodash": "^4.17.20", "react": "16.13.1", "react-dom": "^16.13.1", "react-hook-form": "^6.9.5", "react-native": "0.63.4", "react-native-actionsheet": "^2.4.2", "react-native-adjust": "^4.28.0", "react-native-code-push": "^6.3.0", "react-native-config": "^1.3.3", "react-native-fast-image": "^8.3.4", "react-native-gallery-swiper": "^1.26.4", "react-native-geolocation-service": "^5.1.1", "react-native-gesture-handler": "^1.8.0", "react-native-hyperlink": "^0.0.19", "react-native-image-crop-picker": "^0.35.2", "react-native-image-zoom-viewer": "^3.0.1", "react-native-keyboard-aware-scroll-view": "^0.9.3", "react-native-keyboard-spacer": "^0.4.1", "react-native-linear-gradient": "^2.5.6", "react-native-maps": "^0.27.1", "react-native-markdown-renderer": "^3.2.8", "react-native-permissions": "^2.2.0", "react-native-progress": "^4.1.2", "react-native-push-notification": "^5.1.1", "react-native-rate": "^1.2.4", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-reanimated": "~1.9.0", "react-native-safe-area-context": "^3.1.7", "react-native-screens": "^2.10.1", "react-native-simple-markdown": "^1.1.0", "react-native-simple-toast": "^1.1.3", "react-native-skeleton-content": "^1.0.20", "react-native-splash-screen": "^3.2.0", "react-native-swiper": "^1.6.0", "react-native-tab-view": "^2.15.1", "react-native-unimodules": "^0.10.1", "react-native-video": "https://github.com/r0b0t3d/react-native-video.git#feature/android-fullscreen", "react-native-video-helper": "^1.5.0", "react-native-web-swiper": "^2.1.7", "react-native-webview": "^10.8.3", "react-redux": "^7.2.1", "redux": "^4.0.5", "styled-components": "^5.2.0", "subscriptions-transport-ws": "^0.9.18" }, "devDependencies": { "@babel/core": "^7.8.4", "@babel/runtime": "^7.8.4", "@graphql-codegen/cli": "1.17.10", "@graphql-codegen/introspection": "1.18.0", "@graphql-codegen/typescript": "1.17.10", "@graphql-codegen/typescript-operations": "^1.17.8", "@graphql-codegen/typescript-react-apollo": "2.0.7", "@react-native-community/eslint-config": "1.1.0", "@types/cuid": "^1.3.1", "@types/jest": "^26.0.14", "@types/josa": "^3.0.2", "@types/lodash": "^4.14.162", "@types/react": "^16.9.52", "@types/react-native": "^0.63.25", "@types/react-native-actionsheet": "^2.4.2", "@types/react-native-keyboard-spacer": "^0.4.1", "@types/react-native-push-notification": "^5.0.5", "@types/react-native-video": "^5.0.3", "@types/react-redux": "^7.1.9", "@types/react-test-renderer": "^16.9.3", "@types/styled-components": "^5.1.4", "babel-jest": "^25.1.0", "babel-plugin-module-resolver": "^4.0.0", "eslint": "^6.5.1", "eslint-import-resolver-babel-module": "^5.1.2", "eslint-plugin-import": "^2.22.1", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.59.0", "react-test-renderer": "16.13.1", "typescript": "^4.0.3" }, "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 # Convert all permissions handlers into static libraries pre_install do |installer| installer.pod_targets.each do |pod| if pod.name.start_with?('Permission-') def pod.build_type; # Uncomment one line depending on your CocoaPods version Pod::BuildType.static_library # >= 1.9 # Pod::Target::BuildType.static_library # < 1.9 end end end end require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' require_relative '../node_modules/react-native-unimodules/cocoapods.rb' platform :ios, '10.0' # install! 'cocoapods', # :deterministic_uuids => false target 'drcha' do use_unimodules! config = use_native_modules! use_react_native!(:path => config["reactNativePath"]) permissions_path = '../node_modules/react-native-permissions/ios' pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec" pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec" pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec" pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec" # pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec" # this is needed for audio, video pod 'GoogleSignIn', '~> 5.0.2' # add pods for any other desired Firebase products # https://firebase.google.com/docs/ios/setup#available-pods # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable these next few lines. # use_flipper!({ 'Flipper' => '0.81.0'}) post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' end end flipper_post_install(installer) end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import
#import
#import
#import
#import
#import
// Firebase for GoogleSignin, Analytics
#import
// Microsoft CodePush for OTA updates
#import
// Kakao Login Implementation
#import
// React Native Push Notification IOS
#import
#import
// SplashScreen
#import "RNSplashScreen.h"
#ifdef FB_SONARKIT_ENABLED
#import
#import
#import
#import
#import
#import
static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}
#endif
@interface AppDelegate ()
@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter;
@end
@implementation AppDelegate
// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
// - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
// {
// [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
// }
// Required for the notification event. You must call the completion handler after handling the remote notification.
// - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
// fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
// {
// [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
// }
// Required for the registrationError event.
// - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
// {
// [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
// }
// IOS 10+ Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler
{
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
completionHandler();
}
// IOS 4-10 Required for the localNotification event.
// - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
// {
// [RNCPushNotificationIOS didReceiveLocalNotification:notification];
// }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
// update Kakako accessToken
[KOSession sharedSession].automaticPeriodicRefresh = YES;
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"drcha"
initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[RNSplashScreen show];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
return YES;
}
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}
- (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// If you'd like to export some custom RCTBridgeModules that are not Expo modules, add them here!
return extraModules;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [CodePush bundleURL];
#endif
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if ([KOSession isKakaoAccountLoginCallback:url]) {
return [KOSession handleOpenURL:url];
}
return false;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
options:(NSDictionary *)options {
if ([KOSession isKakaoAccountLoginCallback:url]) {
return [KOSession handleOpenURL:url];
}
return false;
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[KOSession handleDidBecomeActive];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
[KOSession handleDidEnterBackground];
}
@end
```
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? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 playServicesVersion = "17.0.0" androidMapsVersion = "2.0.3" } repositories { google() jcenter() maven { url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com' } maven { url "https://www.jitpack.io" } } dependencies { classpath('com.android.tools.build:gradle:4.0.0') // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0' } } allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } google() jcenter() maven { url 'https://www.jitpack.io' } maven { url 'http://devrepo.kakao.com:8088/nexus/content/groups/public/' } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" project.ext.envConfigFiles = [ debug: "/environments/.env.debug", releasestaging: "/environments/.env.staging", release: "/environments/.env.release", ] apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" apply from: '../../node_modules/react-native-unimodules/gradle.groovy' apply plugin: 'com.google.gms.google-services' // <- Add this line apply plugin: 'com.google.firebase.crashlytics' import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://reactnative.dev/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/react-native-code-push/android/codepush.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.autopedia.drcha" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 28 versionName "1.3.1" vectorDrawables.useSupportLibrary = true } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { storeFile file(RELEASE_STORE_FILE) storePassword RELEASE_STORE_PASSWORD keyAlias RELEASE_KEY_ALIAS keyPassword RELEASE_KEY_PASSWORD } } buildTypes { debug { signingConfig signingConfigs.debug // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key. resValue "string", "CodePushDeploymentKey", '"**DELETED FOR PRIVACY**"' resValue "bool", "FIREBASE_ANALYTICS_DEACTIVATED", "true" } releasestaging { signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" resValue "string", "CodePushDeploymentKey", '"**DELETED FOR PRIVACY**"' resValue "bool", "FIREBASE_ANALYTICS_DEACTIVATED", "true" // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues // Add the following line if not already there matchingFallbacks = ['release'] } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.release // needs to be commentized if want to use appcenter minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" resValue "string", "CodePushDeploymentKey", '"**DELETED FOR PRIVACY**"' resValue "bool", "FIREBASE_ANALYTICS_DEACTIVATED", "false" /* Add the firebaseCrashlytics extension (by default, * it's disabled to improve build speeds) and set * nativeSymbolUploadEnabled to true. */ firebaseCrashlytics { nativeSymbolUploadEnabled true } } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation 'com.android.installreferrer:installreferrer:1.0' addUnimodulesDependencies() debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } compile project(':react-native-video') implementation "androidx.appcompat:appcompat:1.0.0" if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") releasestagingImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'drcha' include ':react-native-video' include ':app', ':react-native-code-push' apply from: '../node_modules/react-native-unimodules/gradle.groovy'; includeUnimodulesProjects() apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer') project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app') ``` #### `MainApplication.java`: ```java package com.autopedia.drcha; // com.myapp should be your package name import com.autopedia.drcha.generated.BasePackageList; import android.app.Application; import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Arrays; import org.unimodules.adapters.react.ModuleRegistryAdapter; import org.unimodules.adapters.react.ReactModuleRegistryProvider; import org.unimodules.core.interfaces.SingletonModule; // CodePush module import com.microsoft.codepush.react.CodePush; import com.brentvatne.react.ReactVideoPackage; // Adjust module // import com.adjust.nativemodule.AdjustPackage; public class MainApplication extends Application implements ReactApplication { private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider( new BasePackageList().getPackageList(), null); private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// example:
// packages.add(new MyReactNativePackage());
// Add unimodules
List unimodules = Arrays.asList(new ModuleRegistryAdapter(mModuleRegistryProvider));
List videos = Arrays.asList( new ReactVideoPackage());
packages.addAll(unimodules);
packages.addAll(videos);
// Add Adjust
// packages.add(new AdjustPackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method
* with something like initializeFlipper(this,
* getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
* We use reflection here to pick up the class that initializes Flipper, since
* Flipper library is not available in release mode
*/
Class> aClass = Class.forName("com.autopedia.drcha.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class).invoke(null, context,
reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
```
#### `AndroidManifest.xml`:
```xml
```
Environment
Click To Expand
**`react-native info` output:** ``` System: OS: macOS 11.2.1 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 659.58 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.12.0 - /usr/local/bin/node Yarn: 1.22.5 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6514223 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 12.0.1 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: ^4.12.0 => 4.13.0 react: 16.13.1 => 16.13.1 react-native: 0.63.4 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [x] Both - **`react-native-firebase` version you're using that has this issue:** - `^11.2.0` - **`Firebase` module(s) you're using that has the issue:** - `@react-native-firebase/remote-config` - **Are you using `TypeScript`?** - `Y` & `^4.0.3`
React Native Firebase
andInvertase
on Twitter for updates on the library.