首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >React native :app:transformClassesWithDexForDebug失败

React native :app:transformClassesWithDexForDebug失败
EN

Stack Overflow用户
提问于 2016-11-01 19:38:00
回答 2查看 2.2K关注 0票数 0

突然之间,我不能再构建react原生应用了。问题标题中提到的任务失败,并显示以下消息:

代码语言:javascript
复制
* 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: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzmu;

我的android/build.gradle

代码语言:javascript
复制
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
        }
    }
}

android/app/build.gradle中的依赖项部分

代码语言:javascript
复制
dependencies {
    compile project(':react-native-keychain')
    compile project(':react-native-fbsdk')
    compile project(':react-native-randombytes')
    compile project(':react-native-barcodescanner')
    compile project(':react-native-camera')
    compile project(':rn-splash-screen')
    compile project(':react-native-code-push')
    compile project(':react-native-vector-icons')
    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-google-signin")){
      exclude group: "com.google.android.gms"
    }
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile project(':react-native-vector-icons')
    compile project(':react-native-code-push')
    compile project(':react-native-onesignal')
}

我听说它是由于冲突而发生的(例如,google play服务声明了两次,或者在一个地方声明为一个特定的服务,而在另一个地方作为一个整体),但找不出问题是什么。这里出了什么问题,我该如何修复它?

EN

回答 2

Stack Overflow用户

发布于 2017-07-20 03:38:43

清理gradle,然后重新构建。

先使用cd android,然后使用./gradlew clean

票数 1
EN

Stack Overflow用户

发布于 2017-03-02 07:37:06

我(有限的)对Android的理解告诉我,你包含了以某种方式共享一个方法名称的独立依赖项。我发现这些错误通常指向我的依赖树中的版本不匹配-在这种情况下,看起来您有多个依赖于com.google.android.gms:play-services-auth的项目。

你听说过的冲突似乎是个问题...exclude group的工作方式可能不符合您的预期。

看一看node_modules/react-native-google-signin/android/build.gradle内部,并将它所依赖的play-services-auth版本与项目app/build.gradle中的play-services-auth进行比较。考虑到您的依赖项列表指向版本9.4.0,您可以尝试将react-native-google-signin依赖项版本设置为匹配,反之亦然。

代码语言:javascript
复制
dependencies {
    compile "com.google.android.gms:play-services-auth:9.4.0"
    compile "com.facebook.react:react-native:+"
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40359306

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档