I'm on RN=0.39, and I've successfully added/linked many other RN libs into my project. This lib is failing on Android builds with the error message below, please advise.
:app:preDexDebug
:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexIndexOverflowException: Cannot merge new index 67249 into a non-jumbo instruction!
Unknown source file : at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:111)
Unknown source file : at com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:26)
Unknown source file : at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:74)
Unknown source file : at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
Unknown source file : at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
Unknown source file : at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:50)
Unknown source file : at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:837)
Unknown source file : at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:811)
Unknown source file : at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:784)
Unknown source file : at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:680)
Unknown source file : at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:534)
Unknown source file : at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
Unknown source file : at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
Unknown source file : at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
Unknown source file : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file : at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file : at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file : at com.android.dx.command.Main.main(Main.java:106)
I can confirm seeing this issue
Is anyone able to build/link successfully?
@GeoffreyPlitt in your android/app/build.gradle add the dexOptions.
android {
dexOptions {
jumboMode true
}
}
That fixed it, thank you!
well it would be nice to not have to enable jumbo option. @GeoffreyPlitt can you reopen?
cc @zo0r @npomfret
reopened
According to @chirag04, enabling jumbo option is not a good solution. So any one finds a better solution for this problem.
hello @janaka120, i'm curious what is the side effect of using jumbo mode? my production apk using jumbo mode & I didn't see any problem to me.
to be clear, i didn't say having jumbo mode is bad. It would be nice to not have to enable it and if we can do something about it in this lib.
That said, jumbo mode is not specific to a library. it can be because other libraries are adding more strings. Enabling pro guard can also help here.
I found out enabling multi-dex can solve the same problem as well, what is the right choice between these two approaches( jumboMode true )
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
Thanks for the explanation @chirag04
Btw, multiDexEnabled make my production apk crashed on startup. But on the other projects, multiDexEnables didn't crash. I think multiDexEnabled is not for silver-bullet :/
please look @ https://developer.android.com/studio/build/multidex.html
enable multidex in your build.gradle file.
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
...
}
@strjoshi thanks,you are right!!
How about if it is an Ionic project? I don't want to mess with the Platform directory, where should this be fixed?
thanks
Hello @chirag04
When i put :
android {
dexOptions {
jumboMode true
}
...
}
in my build.gradle app, i have this error :
Cause: error=2, No such file or directory
@Kayson91 Try to do a full gradle cleanup.
How to resolved this issue in eclipse?
Most helpful comment
@GeoffreyPlitt in your android/app/build.gradle add the dexOptions.