android 我的React Native应用程序在闪屏消失后立即崩溃

plicqrtu  于 2023-06-20  发布在  Android
关注(0)|答案(1)|浏览(125)

我在使用eas构建简单应用程序时遇到了这个问题。expo start运行时运行良好,但构建为apk并安装在android上时崩溃。
应用程序记录的错误是:

com.facebook.react.common.JavascriptException: Error: Requiring unknown module "undefined"., js engine: hermes, stack:
unknownModuleError@1:36453
loadModuleImplementation@1:36262
guardedLoadModule@1:35860
metroRequire@1:35531
?anon_0_@1:1397940
asyncGeneratorStep@1:507933
_next@1:508205
anonymous@1:508157
tryCallTwo@61:8
doResolve@216:24
Promise@82:13
anonymous@1:508078
_getDataFromDB@1:1397896
getDataFromDB@1:1397844
?anon_0_@1:1398217
asyncGeneratorStep@1:507933
_next@1:508205
tryCallOne@53:15
anonymous@139:26
anonymous@1:195409
_callTimer@1:194406
_callReactNativeMicrotasksPass@1:194570
callReactNativeMicrotasks@1:196484
__callReactNativeMicrotasks@1:62331
anonymous@1:61473
__guard@1:62208
flushedQueue@1:61384
invokeCallbackAndReturnFlushedQueue@1:61327

    at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:72)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
    at com.facebook.jni.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:914)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
    at android.os.Looper.loop(Looper.java:224)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
    at java.lang.Thread.run(Thread.java:919)

Package.json

{
  "name": "app-name",
  "version": "1.0.0",
  "author": "njbsyd",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~48.0.18",
    "expo-status-bar": "~1.4.4",
    "react": "18.2.0",
    "react-native": "0.71.8",
    "@expo/vector-icons": "^13.0.0",
    "@react-native-async-storage/async-storage": "1.17.11",
    "@react-navigation/material-bottom-tabs": "^6.2.15",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/stack": "^6.3.16",
    "axios": "^1.4.0",
    "expo-sqlite": "~11.1.1",
    "lottie-ios": "^3.4.0",
    "lottie-react-native": "5.1.4",
    "react-native-action-button": "^2.8.5",
    "react-native-autocomplete-input": "^5.3.2",
    "react-native-element-dropdown": "^2.9.0",
    "react-native-gesture-handler": "~2.9.0",
    "react-native-paper": "^5.8.0",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-vector-icons": "^9.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

eas.json

{
  "cli": {
    "version": ">= 3.13.3"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal"
    },
    "production": {
      "android": {
        "buildType": "apk"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

我用eas build -p android --profile production命令编译。求你了救命
应用程序构建预计将加载,并在启动屏幕上我添加了一些提取功能,并在加载后,应用程序进行到下一个屏幕。但它意外地崩溃了。

blmhpbnm

blmhpbnm1#

我找到了问题的答案。所以我会在Stack Overflow上回答这个问题,以帮助其他遇到同样问题的人。
问题出在一个EAS构建的Android应用程序上,该应用程序在启动画面加载后就会崩溃。The issue in the code was that some files were missing。这是因为EAS压缩文件并将其上传到服务器以进行构建过程。但是,它只包含提交的一部分,并跳过那些在忽略文件(如.gitignore)中指定的文件。

要解决此问题,首先运行以下命令:

eas build:inspect --platform android|ios --stage archive --output <Existing Directory>\folder name for_eas_archive --profile <profile name from eas.json>
此命令可帮助您检查构建中包含了哪些文件。* 用适当的信息替换占位符 *。
然后,打开生成的存档并检查是否有任何文件丢失。在我的例子中,我发现我的Secret File文件丢失了,因为我把它放在了.gitignore文件中,以避免提交到GitHub。
通过执行这些步骤,您可以确定构建中包含哪些文件,并确保不会由于忽略配置而遗漏任何必要的文件。
希望这个解释能有所帮助!

相关问题