App Center构建的Android React Native应用在启动画面后崩溃

5
正如标题所述,我们使用App Center的正常流程无法生产可工作的应用程序发布版本。
当我在本地使用命令行使用发布标志构建应用程序时,输出APK没有任何问题。同样,当构建在App Center上运行时,除了安装并运行后应用程序在启动画面后立即崩溃外,没有任何提示有问题。
我们最近升级到gradle 7.3.3,因此必须升级到JAVA 11,并在App Center的环境变量中添加环境密钥JAVA_HOME : $(JAVA_HOME_11_X64)
有其他人遇到过这种情况吗?
最大的问题是,如果无法在本地生成的发布版中复制此问题,则无法解决问题。由App Center生成的发布版没有任何错误记录。它会静默崩溃。
app center日志中唯一引起关注的部分似乎如下所示。
编辑:为了使事情更有趣,我在build.gradle的发布配置中添加了debuggable true,那个构建运行得很好...不知道那么大的改变是什么。
info Writing bundle output to:, /Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle
info Writing sourcemap output to:, /Users/runner/work/1/s/android/app/build/intermediates/sourcemaps/react/release/index.android.bundle.packager.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 201 asset files
info Done copying assets
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:3242:23: warning: the variable "DebuggerInternal" was not declared in function "__shouldPauseOnThrow"
        return typeof DebuggerInternal !== 'undefined' && DebuggerInternal.shouldPauseOnThrow === true;
                      ^~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:6950:7: warning: the variable "setTimeout" was not declared in function "logCapturedError"
      setTimeout(function () {
      ^~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:5337:23: warning: the variable "clearTimeout" was not declared in anonymous function " 153#"
      cancelTimeout = clearTimeout;
                      ^~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:9717:30: warning: the variable "__REACT_DEVTOOLS_GLOBAL_HOOK__" was not declared in anonymous function " 153#"
  if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:9735:68: warning: the variable "nativeFabricUIManager" was not declared in anonymous function " 187#"
    null != handle._nativeTag && (handle._internalInstanceHandle ? nativeFabricUIManager.dispatchCommand(handle._internalInstanceHandle.stateNode.node, command, args) : _$$_REQUIRE(_dependencyMap[2]).UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args));
                                                                   ^~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:10629:5: warning: the variable "setImmediate" was not declared in function "handleResolved"
    setImmediate(function () {
    ^~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14139:12: warning: the variable "fetch" was not declared in anonymous function " 352#"
    fetch: fetch,
           ^~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14140:14: warning: the variable "Headers" was not declared in anonymous function " 352#"
    Headers: Headers,
             ^~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14141:14: warning: the variable "Request" was not declared in anonymous function " 352#"
    Request: Request,
             ^~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14142:15: warning: the variable "Response" was not declared in anonymous function " 352#"
    Response: Response
              ^~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14318:24: warning: the variable "FileReader" was not declared in function "readBlobAsArrayBuffer"
      var reader = new FileReader();
                       ^~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14363:36: warning: the variable "Blob" was not declared in anonymous function " 363#"
        } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
                                   ^~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14365:40: warning: the variable "FormData" was not declared in anonymous function " 363#"
        } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
                                       ^~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14367:44: warning: the variable "URLSearchParams" was not declared in anonymous function " 363#"
        } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
                                           ^~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14644:23: warning: the variable "XMLHttpRequest" was not declared in anonymous function " 372#"
        var xhr = new XMLHttpRequest();
                      ^~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:14151:76: warning: the variable "self" was not declared in anonymous function " 355#"
    var global = typeof globalThis !== 'undefined' && globalThis || typeof self !== 'undefined' && self || typeof global !== 'undefined' && global;
                                                                           ^~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:19151:27: warning: the variable "performance" was not declared in anonymous function " 522#"
  if ("object" === typeof performance && "function" === typeof performance.now) {
                          ^~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:19166:62: warning: the variable "MessageChannel" was not declared in anonymous function " 522#"
  if ("undefined" === typeof window || "function" !== typeof MessageChannel) {
                                                             ^~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:24720:32: warning: the variable "requestAnimationFrame" was not declared in function "onUpdate"
        this._animationFrame = requestAnimationFrame(this.onUpdate.bind(this));
                               ^~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:61349:16: warning: the variable "Intl" was not declared in function "intlFormat"
    return new Intl.DateTimeFormat((_localeOptions = localeOptions) === null || _localeOptions === undefined ? undefined : _localeOptions.locale, formatOptions).format(date);
               ^~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:75869:16: warning: the variable "navigator" was not declared in function "isStandardBrowserEnv"
    if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || navigator.product === 'NativeScript' || navigator.product === 'NS')) {
               ^~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:76189:51: warning: the variable "btoa" was not declared in function "dispatchXhrRequest"
        requestHeaders.Authorization = 'Basic ' + btoa(***name + ':' + password);
                                                  ^~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:77621:32: warning: the variable "AggregateError" was not declared in anonymous function " 2057#"
    '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
                               ^~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:77630:25: warning: the variable "Atomics" was not declared in anonymous function " 2057#"
    '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
                        ^~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:77631:24: warning: the variable "BigInt" was not declared in anonymous function " 2057#"
    '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
                       ^~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:77644:38: warning: the variable "FinalizationRegistry" was not declared in anonymous function " 2057#"
    '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
                                     ^~~~~~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:77669:35: warning: the variable "SharedArrayBuffer" was not declared in anonymous function " 2057#"
    '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
                                  ^~~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:77683:25: warning: the variable "WeakRef" was not declared in anonymous function " 2057#"
    '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
                        ^~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:142236:41: warning: the variable "getComputedStyle" was not declared in function "generateLayersText"
        var computedFontSize = parseInt(getComputedStyle(node).fontSize, 10);
                                        ^~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:140522:18: warning: the variable "MutationObserver" was not declared in anonymous function " 3601#"
      if (typeof MutationObserver !== 'undefined') _MUTATION_OBSERVER = MutationObserver;
                 ^~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:171057:32: warning: the variable "crypto" was not declared in function "rng"
      getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
                               ^~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:171057:130: warning: the variable "msCrypto" was not declared in function "rng"
      getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
                                                                                                                                 ^~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:225075:18: warning: Direct call to eval(), but lexical scope is not supported.
          return eval("(".concat(source, ")"));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:225079:19: warning: Direct call to eval(), but lexical scope is not supported.
          var f = eval("(".concat(source, ")"));
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/1/s/android/app/build/generated/assets/react/release/index.android.bundle:227293:17: warning: the variable "__fbBatchedBridge" was not declared in function "getHost"
    if ((typeof __fbBatchedBridge === "undefined" ? "undefined" : _typeof(__fbBatchedBridge)) !== 'object' || hostname !== 'localhost' && hostname !== '127.0.0.1') {
                ^~~~~~~~~~~~~~~~~

3
你也遇到了同样的问题吗?你找到任何解决方案了吗? - RoyalBosS
我在这里的帖子上得到了一些回复,可能对你有用。https://github.com/facebook/react-native/issues/33029#issuecomment-1029159085 - Jake Giles-Phillips
1个回答

0

我也曾遇到过启动画面的同样错误。

这是我的解决方法。在 build.gradle (android > app > build.gradle) 中添加:

debuggable true

问题就解决了。

buildTypes {
        ...
        release {
            debuggable true
            ...
        }
    }

之后我成功获取了发布版 APK。

但这似乎不是一个合理的解决方案,在调试模式下发布。

React Native版本为0.65.1,gradlew版本为6.9。


1
目前你的回答不够清晰,请编辑并添加更多细节,以帮助其他人理解它如何回答问题。你可以在帮助中心找到有关如何编写好答案的更多信息。 - Vikram Parimi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接