首页 > 解决方案 > React Native Android Bundle 发布挂起:app:transformDexArchiveWithDexMergerForRelease

问题描述

运行react-native run-androidand react-native run-android --variant=release,应用程序在 Android 设备上构建和运行良好。iOS 构建和发布也可以正常工作。我已按照此处的签名说明进行操作。

当我运行./gradlew bundleRelease前几个任务时,相当快地成功完成,但进程挂起:app:transformDexArchiveWithDexMergerForRelease。它已经执行了一个多小时。以下是完整的日志。我不确定如何最好地调试它。我可以在命令中添加任何标志吗?

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: API 'variant.getAssemble()' is obsolete and has been replaced with 'variant.getAssembleProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getAssemble(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessManifest()' is obsolete and has been replaced with 'variantOutput.getProcessManifestProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessManifest(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getPackageApplication(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getExternalNativeBuildTasks(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Configure project :lottie-react-native
publishNonDefault is deprecated and has no effect anymore. All variants are now published.

> Configure project :react-native-cookies
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.0.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from /Users/davidadler/Projects/app/node_modules/react-native/android

> Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /Users/davidadler/Projects/app/node_modules/react-native/android

> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, /Users/davidadler/Projects/app/android/app/build/generated/assets/react/release/index.android.bundle
info Done writing bundle output
info Copying 22 asset files
info Done copying assets

> Task :app:processReleaseGoogleServices
Parsing json file: /Users/davidadler/Projects/app/android/app/google-services.json

> Task :app:generateBundledResourcesHashRelease
03a478725b08cbc57d0ab5d9fb1cc3a78e325c451b00efcc325a1b5deb1e79e9
<==========---> 79% EXECUTING [10m 0s]
<==========---> 79% EXECUTING [10m 0s]rForRelease
<==========---> 79% EXECUTING [10m 0s]rForRelease
<==========---> 79% EXECUTING [10m 1s]rForRelease
<==========---> 79% EXECUTING [10m 1s]rForRelease
<==========---> 79% EXECUTING [10m 1s]rForRelease
<==========---> 79% EXECUTING [44m 51s]
<==========---> 79% EXECUTING [44m 51s]ForRelease
<==========---> 79% EXECUTING [44m 51s]ForRelease
<==========---> 79% EXECUTING [45m 4s]
> :app:transformDexArchiveWithDexMergerForRelease

标签: androidreact-native

解决方案


同样的问题,我正在尝试将我们的应用程序从 0.59.2 更新到 0.59.9

它似乎已经通过添加org.gradle.jvmargs=-Xmx2048M -XX\:MaxHeapSize\=32g来解决它android/gradle.properties- 参考这个答案Gradle build of Android app in VSTS failed after running out of memory

此外,我也有这个在android部分android/app/build.gradle

android {
  ...
  ...
  dexOptions {
    incremental true
    javaMaxHeapSize "4G"
  }
  ...
  ...
}

推荐阅读