简体   繁体   English

反应原生:app:transformClassesWithDexForDebug失败

[英]React native :app:transformClassesWithDexForDebug FAILED

Suddenly I can no longer build a react native app. 突然我无法再构建一个本机应用程序了。 The task, mentioned in the question title fails with following message: 问题标题中提到的任务失败,并显示以下消息:

* 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;

My android/build.gradle : 我的android/build.gradle

// 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"
        }
    }
}

And dependencies section from android/app/build.gradle : android/app/build.gradle依赖项部分:

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')
}

I've heard that it occurs due to conflicts (eg google play services declared twice, or declared as a particular service in one place and as a whole in another place) But can't figure out what the problem is. 我听说它是​​由于冲突而发生的(例如,Google Play服务声明了两次,或者在一个地方声明为特定服务,而在另一个地方则声明为一个整体),但无法弄清楚问题出在哪里。 What's wrong here and how can I fix it? 这里有什么问题,我该如何解决?

My (limited) understanding of Android tells me that you are including seperate dependencies that share a method name in some way or another. 我对Android的(有限的)理解告诉我,您正在包括以某种方式共享方法名称的独立依赖项。 I've found these errors to typically point to a version mismatch in my dependency tree - in this case it looks like you have multiple projects depending on com.google.android.gms:play-services-auth . 我发现这些错误通常指向我的依赖项树中的版本不匹配-在这种情况下,看起来您有多个项目取决于com.google.android.gms:play-services-auth

The conflicts you've heard of seem to be problem... exclude group may not be working how you intend. 您听说过的冲突似乎有问题... exclude group可能无法按您的预期工作。

Take a look inside node_modules/react-native-google-signin/android/build.gradle and compare the version of play-services-auth it depends on against the play-services-auth in your project's app/build.gradle . 看看里面node_modules/react-native-google-signin/android/build.gradle和比较的版本play-services-auth这取决于对play-services-auth在项目的app/build.gradle Considering your dependency list points at version 9.4.0 you can try setting the react-native-google-signin dependency version to match, or vice-versa. 考虑到您的依赖项列表指向9.4.0版,您可以尝试将react-native-google-signin依赖项版本设置为匹配,反之亦然。

dependencies {
    compile "com.google.android.gms:play-services-auth:9.4.0"
    compile "com.facebook.react:react-native:+"
}

clean gradle then build again. 清洁gradle,然后重新构建。

cd android then ./gradlew clean cd android然后./gradlew clean

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 react native中任务':app:transformClassesWithDexForDebug'的执行失败 - Execution failed for task ':app:transformClassesWithDexForDebug' in react native React Native + Android:transformClassesWithDexForDebug失败 - React Native + Android: transformClassesWithDexForDebug FAILED 运行 react-native run-android 时任务 ':app:transformClassesWithDexForDebug' 执行失败 - Execution failed for task ':app:transformClassesWithDexForDebug' when running react-native run-android 任务执行失败':app:transformClassesWithDexForDebug' - Execution failed for task ':app:transformClassesWithDexForDebug' 任务':app:transformClassesWithDexForDebug'的接收失败 - Exeception failed for task ':app:transformClassesWithDexForDebug' 小型应用程序中的任务':app:transformClassesWithDexForDebug'执行失败 - Execution failed for task ':app:transformClassesWithDexForDebug' in small app 错误:任务“:app:transformClassesWithDexForDebug”的执行失败 - Error:Execution failed for task ':app:transformClassesWithDexForDebug' 任务':app:transformClassesWithDexForDebug'的执行失败-JDK问题? - Execution failed for task ':app:transformClassesWithDexForDebug' - JDK issue? 错误:任务':app:transformClassesWithDexForDebug'Gradle的执行失败 - Error:Execution failed for task ':app:transformClassesWithDexForDebug' Gradle TransformException:错误:任务“:app:transformClassesWithDexForDebug”的执行失败 - TransformException : Error:Execution failed for task ':app:transformClassesWithDexForDebug'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM