我有一个在iOS上运行良好的React本地应用程序,但是当我尝试在Android上运行时,我会得到以下错误。
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谷歌这些错误,我得到建议删除节点模块或运行的反应-本机-清洁项目,我已经尝试了,但没有结果。有什么方法可以获得关于这些错误的更具体的信息吗?这个应用程序很大,所以我不确定TypeError在哪里发生。
发布于 2022-09-15 15:23:16
你用i18next吗?对我来说,这是i18next配置。检测方法看起来是这样的。
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在ios下为null。因此,我们不得不将const { settings } = SettingsManager;移动到PlatformHelper.isIOS()块中。
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];
},https://stackoverflow.com/questions/71520374
复制相似问题