使用 64k+ 方法 React Native Android 应用程序

Dan*_*eng 0 react-native react-native-android

我在使用 react-native run-android 运行 RN Android 应用程序时遇到问题

它在构建阶段抛出异常并且无法找出问题所在。

Execution failed for task ':react-native-firebase:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Run Code Online (Sandbox Code Playgroud)

我在网上尝试了各种解决方案,一切都在进行中。尝试过的解决方案是启用 multiDex 并增加 dexOptions 中的 javaMaxHeapSize。

此错误可被视为依赖于库或组件,但它会发生在任何类型的超过 64k 限制的应用程序中。

还有一件事:它在 Android Studio 中编译没有任何问题

Tia*_*vêa 5

使用 react 0.60 我遇到了这个问题,并将 multiDexEnabled true 添加到我的 defaultConfig (android/app/build.gradle) 修复了它:

android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
   }
   ...
}
Run Code Online (Sandbox Code Playgroud)