【问题标题】:':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.com.android.builder.dexing.DexArchiveMergerException:':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.com.android.builder.dexing.DexArchiveMergerException:
【发布时间】:2020-02-01 16:22:05
【问题描述】:

合并 dex 档案时出错:.dex 文件中的方法引用数不能超过 64K。

在添加 react-native-firebase/admob 之前代码可以正常工作。但是在添加该库构建失败后。当我删除构建的反应导航时。为什么这两个库不能使用同一个应用?

这是我的 app.json 文件和 build.gradle 文件。

    "@react-native-community/masked-view": "^0.1.6",
    "@react-native-firebase/admob": "^6.2.0",
    "@react-native-firebase/app": "^6.2.0",
    "react": "16.8.6",
    "react-native": "0.60.0",
    "react-native-gesture-handler": "^1.5.3",
    "react-native-image-zoom-viewer": "^2.2.27",
    "react-native-indicators": "^0.17.0",
    "react-native-modal": "^11.5.3",
    "react-native-reanimated": "^1.7.0",
    "react-native-responsive-dimensions": "^3.0.0",
    "react-native-safe-area-context": "^0.6.2",
    "react-native-screens": "^2.0.0-alpha.29",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^2.0.16"
  },

buildscript {
   ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}```

【问题讨论】:

    标签: android firebase react-native react-navigation


    【解决方案1】:

    非常感谢,终于解决了这个问题。我将代码更改为

    defaultConfig {
    // ...
    multiDexEnabled true }
    

    我在 android/app/build.gradle 文件的 defaultconfig 中添加了 multiDexEnabled true 行

    【讨论】:

      【解决方案2】:

      如果 .dex 文件中的方法引用数超过 64K,则必须在 android 中使用 Multidex。想知道如何使用Multidex请看doc

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-14
        相关资源
        最近更新 更多