繁体   English   中英

任务':app:transformClassesWithJarMergingForDebug'的React Native执行失败

[英]React Native Execution failed for task ':app:transformClassesWithJarMergingForDebug'

您好,我读过类似问题的人的类似帖子,但是我无法确定解决方法。 我正在使用本机反应,并且已经清理了项目。 这是我遇到的错误,我不确定还应该尝试什么? 我收到有关NKD平台的警告,但目前不确定。

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zzf.class

android / app / build.gradle

apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'

import com.android.build.OutputFile

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.art.android"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
signingConfigs {
        release {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
    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"
            signingConfig signingConfigs.release
        }
    }
    // 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-vector-icons')
    compile project(':react-native-fcm')
    compile project(':react-native-code-push')
    compile project(':tipsi-stripe')
    compile project(':react-native-splash-screen')
    compile project(':react-native-image-resizer')
    compile project(':react-native-image-picker')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-camera')
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

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

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.3.3'
        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 {
        // Add jitpack repository (added by tipsi-stripe)
        maven { url "https://jitpack.io" }
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

更新1:添加Package.json

  "dependencies": {
    "analytics-react-native": "^1.1.0",
    "axios": "^0.16.2",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "bluebird": "^3.5.0",
    "buffer": "^5.0.6",
    "eslint": "^4.1.1",
    "eslint-plugin-react": "^7.1.0",
    "events": "^1.1.1",
    "fbemitter": "^2.1.1",
    "firebase": "^4.0.0",
    "firebase-admin": "^5.0.0",
    "firebase-functions": "^0.5.8",
    "lodash": "^4.17.4",
    "md5": "^2.2.1",
    "prop-types": "^15.5.10",
    "react": "16.0.0-alpha.6",
    "react-native": "^0.44.0",
    "react-native-camera": "^0.9.0",
    "react-native-code-push": "2.1.1-beta",
    "react-native-elements": "^0.17.0",
    "react-native-fcm": "^9.1.0",
    "react-native-fetch-blob": "^0.10.5",
    "react-native-gifted-chat": "^0.1.4",
    "react-native-icon-badge": "^1.1.3",
    "react-native-image-picker": "^0.26.3",
    "react-native-image-resizer": "^0.1.0",
    "react-native-keyboard-aware-scroll-view": "^0.2.9",
    "react-native-offline": "^3.1.0",
    "react-native-qrcode": "^0.2.3",
    "react-native-splash-screen": "^3.0.0",
    "react-native-swiper": "^1.5.4",
    "react-native-vector-icons": "^4.4.0",
    "react-navigation": "^1.0.0-beta.11",
    "react-redux": "^4.4.5",
    "react-router": "^2.5.1",
    "redux": "^3.6.0",
    "redux-observable": "^0.14.1",
    "redux-persist": "^4.0.0-alpha5",
    "redux-thunk": "^2.1.0",
    "source-map": "^0.5.6",
    "stripe": "^4.23.1",
    "tipsi-stripe": "^3.2.0",
    "twilio-chat": "^1.0.3",
    "twilio-common": "^0.1.6",
    "util": "^0.10.3"
  },

更新2问题是由我需要添加的tips-stripe引起的

compile(project(':tipsi-stripe')){
  exclude group: 'com.google.android.gms'
}

compile ('com.google.android.gms:play-services-wallet:10.0.1'){
 force=true
}

问题是此编译中的firebase版本

compile 'com.google.firebase:firebase-core:10.0.1' 

它应该与编译的内容相同

compile project(':react-native-fcm')

因为它也取决于firebase来修复该添加

 compile ('com.google.firebase:firebase-core:10.0.1'){
  force=true
}
compile ('com.google.firebase:firebase-messaging:10.0.1'){
  force=true
}
compile ('com.google.android.gms:play-services-base:10.0.1'){
  force=true
}

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM