diff --git a/docs/enabling-multidex.md b/docs/enabling-multidex.md new file mode 100644 index 00000000..7b58dde8 --- /dev/null +++ b/docs/enabling-multidex.md @@ -0,0 +1,35 @@ +--- +title: Enabling Multidex +description: Learn how to enable multidex on your Android application. +--- + +As more native dependencies are added to your project, it may bump you over the +64k method limit on the Android build system. Once this limit has been reached, you will start to see the following error +whilst attempting to build your Android application: + +``` +Execution failed for task ':app:mergeDexDebug'. +``` + +To learn more about multidex, view the offical [Android documentation](https://developer.android.com/studio/build/multidex#mdex-gradle). + +## Enabling Multidex + +Open the `/android/app/build.gradle` file. Under `dependencies` we need to add the module, and then enable it +within out `defaultConfig`: + +```groovy +android { + defaultConfig { + // ... + multiDexEnabled true + } + // ... +} + +dependencies { + implementation 'com.android.support:multidex:1.0.3' +} +``` + +Once added, rebuild your application: `npx react-native run-android`. diff --git a/docs/firestore/enabling-multidex.md b/docs/firestore/enabling-multidex.md deleted file mode 100644 index 0c87ace3..00000000 --- a/docs/firestore/enabling-multidex.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: Enabling Multidex -description: The Cloud Firestore SDK on Android can sometimes cause Dex errors, learn how to fix them. ---- - -The Android Firebase Firestore SDK is a large library, and in some scenarios it may bump you over the -65k method limit on the Android build system. - -If you have added Cloud Firestore as a dependency and your application build is now failing with the following error, -you'll need to [enable multidex](https://developer.android.com/studio/build/multidex#mdex-gradle). - -`Execution failed for task ':app:mergeDexDebug'.` - -## Enabling Multidex - -Open the `/android/app/build.gradle` file. Under `dependencies` we need to add the module, and then enable it -within out `defaultConfig`: - -```groovy -android { - defaultConfig { - // ... - multiDexEnabled true - } - // ... -} - -dependencies { - implementation 'com.android.support:multidex:1.0.3' -} -``` - -Once added, rebuild your application: `npx react-native run-android`. diff --git a/docs/firestore/usage/index.md b/docs/firestore/usage/index.md index 47cb5bdc..09d70c36 100644 --- a/docs/firestore/usage/index.md +++ b/docs/firestore/usage/index.md @@ -25,8 +25,8 @@ cd ios/ && pod install If you're using an older version of React Native without autolinking support, or wish to integrate into an existing project, you can follow the manual installation steps for [iOS](/firestore/usage/installation/ios) and [Android](firestore/usage/installation/android). -In some scenarios, your Android build may fail with the `app:mergeDexDebug` error. This required that multidex is enabled -for your application. To learn more, read the [Enabling Multidex](/firestore/enabling-multidex) documentation. +If you have started to receive a `app:mergeDexDebug` error after adding Cloud Firestore, please read the +[Enabling Multidex](/enabling-multidex) documentation for more information on how to resolve this error. # What does it do diff --git a/docs/index.md b/docs/index.md index 60d0d5cc..9bfd8c0a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -156,6 +156,15 @@ you can follow the manual installation steps for [iOS](/install-ios) and [Androi # Miscellaneous +## Android Enabling Multidex + +As your application starts to grow with more native dependencies, your builds may start to fail with the common +`Execution failed for task ':app:mergeDexDebug'` error. This error occurs when Android reaches the +[64k methods](https://developer.android.com/studio/build/multidex) limit. + +One common solution is to [enable multidex](/enabling-multidex) support for Android. This is a common solution to solving +the problem, however it is recommended you read the Android documentation to understand how it may impact your application. + ## Hermes Support At this time, React Native Firebase does not support the [Hermes](https://hermesengine.dev/) JavaScript engine due to