react-native-map将字节码转换为dex出错:WithDexForDebug

问题描述:

我已经失去了2天的时间,而且我无法构建使用react-native-map的react-native项目。这是我的错误,当我运行react-native run-androidreact-native-map将字节码转换为dex出错:WithDexForDebug

敏捷:错误字节码转换到DEX:WithDexForDebug原因: com.android.dex.DexException:多DEX文件定义 LCOM /谷歌/安卓/ GMS/AUTH/API /登入/内部/ ZZG; 意外的*例外:com.android.dex.DexException:多个dex文件定义为 Lcom/google/android/gms/auth/api/signin/internal/zzg;

这是我的package.json文件

{ 
    "name": "hackathon", 
    "version": "0.0.1", 
    "private": true, 
    "scripts": { 
    "start": "node node_modules/react-native/local-cli/cli.js start", 
    "test": "jest" 
    }, 
    "dependencies": { 
    "react": "16.0.0-beta.5", 
    "react-native": "0.49.3", 
    "react-native-maps": "^0.17.0", 
    "react-navigation": "git+https://github.com/react-community/react-navigation.git" 
    }, 
    "devDependencies": { 
    "babel-jest": "21.2.0", 
    "babel-preset-react-native": "4.0.0", 
    "jest": "21.2.1", 
    "react-test-renderer": "16.0.0-beta.5" 
    }, 
    "jest": { 
    "preset": "react-native" 
    } 
} 

我已经跑了react-native rlink react-native-maps

而且,这里是我的android/build.gradle文件

​​

这是我​​文件

apply plugin: "com.android.application" 

import com.android.build.OutputFile 

project.ext.react = [ 
    entryFile: "index.js" 
] 

apply from: "../../node_modules/react-native/react.gradle" 

def enableSeparateBuildPerCPUArchitecture = false 

def enableProguardInReleaseBuilds = false 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.hackathon" 
     minSdkVersion 16 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
     ndk { 
      abiFilters "armeabi-v7a", "x86" 
     } 
    } 
    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 project(':react-native-maps') 
    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 'com.google.android.gms:play-services:10.0.1' 
} 

// Run this once to be able to run the application with BUCK 
// puts all compile dependencies into folder libs for BUCK to use 
task copyDownloadableDepsToLibs(type: Copy) { 
    from configurations.compile 
    into 'libs' 
} 

我从Windows 10做我的发展在我的Android工作室,我敢肯定我安装了Google Play服务。当我查看计算机硬盘时,确实看到Google Play服务存在:10.0.1。

如何让我的项目编译成可以使用react-native-maps

我从我的​​文件中删除了行compile 'com.google.android.gms:play-services:10.0.1',然后一切正常。

+0

但它没有让一些东西崩溃?我的意思是你不需要这种配置? –