意外的顶级异常(反应原生)

时间:2016-06-06 12:50:41

标签: android reactjs react-native

我在构建项目时出现此错误,这是一个反应原生的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)

这是我的傻瓜:

`申请自:“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
        }
    }
}

}

dependencies { compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules compile project(':react-native-vector-icons') compile project(':react-native-share') }

我安装了所有必需的依赖项(google存储库,...),删除了build文件夹,但我总是收到此错误。

如果您有任何链接或提示,谢谢!而且我不能发布一个独特的代码,堆栈溢出不会这样做,grrrrr!

1 个答案:

答案 0 :(得分:12)

问题解决了!做了一些更改,之后cd android/ && ./gradlew clean修复了它!