我在https://facebook.github.io/react-native/docs/getting-started.html非常仔细地按照说明为我的React Native项目设置了Android AVD环境。我在现有项目上运行react-native run-android
时出现此错误:
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzble;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzble;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
:app:transformClassesWithDexForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
我能够运行一个新的react-native init AwesomeProject
就好了,所以我假设它与我现有的项目及其依赖性有关。我知道Firebase的Firestack可能是罪魁祸首,因为它对build.gradle
文件进行了一些更改。我搜索了StackOverflow和Google并尝试了许多sugestions。没有用。我从阅读中得知,我的build.gradle
文件中可能存在可能是原因的内容,所以我也发布了它们。
root build.grade
app build.gradle