Alright, so really just posting as a sanity check, and making sure I'm not doing my android all wrong. Essentially, it seems needing to use multiDexEnabled true
is not best practice, as it means the app is getting "big", aka bloated. But it takes very little to get there with the tools I'm using, which I'll outline below.
TL;DR: Using multidex seems to be bad practice, is there a different solution?
Starting with a vanilla Ignite CLI Bowser project, a template engine for React Native, and adding the React Native Facebook SDK according to the official guide, results in a build error for the android application.
ignite new TestApp
cd TestApp && yarn add react-native-fbsdk && npx react-native link react-native-fbsdk
Following Android Guide, make relevant changes to
TestApp/android/app/src/main/java/com/testapp/MainApplication.java
and TestApp/android/settings.gradle
Then, following the linked Facebook SDK guide (auth wall), made the relevant changes to TestApp/android/app/build.gradle
, TestApp/android/app/src/main/res/values/strings.xml
and TestApp/android/app/src/main/AndroidManifest.xml
Then, running npx react-native run-android
, results in the following build error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
More searches point to a fix of adding multiDexEnabled true
to defaultConfig
within the module build.gradle
, which does fix the error. The issue, is most of those solutions also lead to others pointing out poor library management, importing too much, etc.
So, am I doing something wrong, or is this just the result of using Facebook SDK and Ignite CLI and there's nothing I can do about it? I just worry, as I was hoping to add more than one provider's OAuth to the application, but don't want a bloated application that never loads.