Reputation: 129
I have a React Native application that runs fine on iOS, however when I try and run on Android I get the following error.
ERROR TypeError: Cannot read property 'settings' of null, js engine: hermes
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
Googling these errors I get advice to delete node modules or run react-native-clean-project which I have tried with no result. Is there some way to get more specific information about these errors? The Application is quite large so I am not sure where the TypeError is occurring exactly
Upvotes: 1
Views: 2568
Reputation: 1181
Do you use i18next? For me it was the i18next configuration. The detect method looked something like this.
i18next
.use({
type: 'languageDetector',
init: () => {
},
cacheUserLanguage: () => {
},
detect: () => {
const { SettingsManager, I18nManager } = NativeModules;
const { settings } = SettingsManager;
let locale;
if (PlatformHelper.isIOS()) {
locale = settings.AppleLocale || settings.AppleLanguages[0];
} else {
locale = I18nManager.localeIdentifier;
}
if (_.isEmpty(locale)) {
locale = 'en';
}
return locale.split('_')[0];
},
})
SettingsManager is null under ios. So we had to move const { settings } = SettingsManager;
inside the PlatformHelper.isIOS()
block.
detect: () => {
const { SettingsManager, I18nManager } = NativeModules;
let locale;
if (PlatformHelper.isIOS()) {
const { settings } = SettingsManager;
locale = settings.AppleLocale || settings.AppleLanguages[0];
} else {
locale = I18nManager.localeIdentifier;
}
if (_.isEmpty(locale)) {
locale = 'en';
}
return locale.split('_')[0];
},
Upvotes: 3