我构建项目时出现此错误,它是一个反应原生的android项目:
UNEXPECTED TOP-LEVEL EXCEPTION :
com.android.dex.DexException: Multiple dex files define Landroid/support/v7/app/ActionBar$Callback;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
这是我的傻瓜:
`apply from:“react.gradle”
申请自:“../../node_modules/react-native-vector-icons/fonts.gradle”
def enableSeparateBuildPercpuArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion“23.0.1”`
defaultConfig {
applicationId "com.movieproject"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a","x86"
}
}
signingConfigs {
release {
}
}
splits {
abi {
reset()
enable enableSeparateBuildPercpuArchitecture
universalApk false // If true,also generate a universal APK
include "armeabi-v7a","x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"),"proguard-rules.pro"
}
}
// applicationVariants are e.g. debug,release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture,set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1,"x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug,universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
依赖{
编译fileTree(dir:“libs”,包括:[“* .jar”])
编译“com.android.support:appcompat-v7:23.0.1”
编译“com.facebook.react:react-native:”//来自node_modules
编译项目(‘:react-native-vector-icons’)
编译项目(‘:react-native-share’)
}
最佳答案
问题解决了 !做了一些改变,然后cd了android /&& ./gradlew清理修复它!