使用 App Center 构建时 Android React Native 应用程序在闪屏后崩溃

Jak*_*ips 5 android gradle react-native visual-studio-app-center

正如标题所示,我们正在努力使用应用程序中心中的正常管道来生成应用程序的工作发布版本。当我在本地使用发布标志通过命令行构建应用程序时,输出 APK 没有问题。

同样,当构建在应用程序中心上运行时,也没有任何迹象表明构建存在问题,除非安装并运行后,应用程序在启动屏幕后立即崩溃。

我们最近升级到了 gradle 7.3.3,因此必须为此升级到 JAVA 11,同样将环境密钥添加JAVA_HOME : $(JAVA_HOME_11_X64)到 App Center 上的环境变量中。

有人遇到过这种情况么。

最大的问题是,如果无法在本地生成的发布版本中复制此内容,我们就无法弄清楚如何调试问题,应用程序中心生成的发布版本没有任何错误日志记录。它悄无声息地崩溃了。

应用程序中心日志中唯一相关的部分如下所示。

编辑:为了让事情变得更有趣,我添加debuggable true到了 build.gradle 的发布配置中,并且该构建运行良好......不知道发生了什么巨大的变化

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') {
                ^~~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)

小智 0

我在闪屏上遇到了同样的错误。

这解决了我的问题。添加:

可调试 true

在 build.gradle 内部(android > app > build.gradle)

buildTypes {
        ...
        release {
            debuggable true
            ...
        }
    }
Run Code Online (Sandbox Code Playgroud)

之后我就能够获得发布的APK。

但这在调试模式中似乎不是那么合乎逻辑的解决方案。

反应本机 0.65.1 gradlew 6.9