React Native构建失败执行任务':app:checkDebugDuplicateClasses'失败

时间:2020-10-27 11:43:19

标签: java android reactjs react-native mobile

installreferrer payu 一起使用sdk.iam以响应本机尝试集成payumobile进行支付集成的错误任务':app的执行失败: checkDebugDuplicateClasses”。

``` 失败:构建失败,并出现异常。

*  What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.google.android.a.a found in modules jetified-installreferrer-2.1-runtime.jar (com.android.installreferrer:installreferrer:2.1) and jetified-payu-gpay-1.3.3-runtime.jar (com.payu.gpay:payu-gpay:1.3.3)
  Duplicate class com.google.android.a.b found in modules jetified-installreferrer-2.1-runtime.jar (com.android.installreferrer:installreferrer:2.1) and jetified-payu-gpay-1.3.3-runtime.jar (com.payu.gpay:payu-gpay:1.3.3)
  Duplicate class com.google.android.a.c found in modules jetified-installreferrer-2.1-runtime.jar (com.android.installreferrer:installreferrer:2.1) and jetified-payu-gpay-1.3.3-runtime.jar (com.payu.gpay:payu-gpay:1.3.3)```

android / build.gradle

    buildscript {
        ext {
            buildToolsVersion = "29.0.2"
            minSdkVersion = 21
            compileSdkVersion = 29
            targetSdkVersion = 29
            kotlinVersion = "1.3.72"
            androidXCore = "1.0.2"
        }
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:4.0.2'
            classpath 'com.google.gms:google-services:4.3.3'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    //        classpath 'com.google.firebase:perf-plugin:1.3.1'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            mavenLocal()
            maven {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url("$rootDir/../node_modules/react-native/android")
            }
            maven {
                // Android JSC is installed from npm
                url("$rootDir/../node_modules/jsc-android/dist")
            }
            // ADD THIS
            maven { url 'https://maven.google.com' }
    
            // ADD THIS
            maven { url "https://www.jitpack.io" }
            maven { url 'https://maven.fabric.io/public' }
            maven {
                url "https://sdk.smartlook.com/android/release"
            }
            maven { url "https://phonepe.bintray.com/PhonePeIntentSDK" }
            google()
            jcenter()
        }
    } 

我在应用程序build.gradle中添加了依赖项,它引发错误 android / app / build.gradle


    android {
        compileSdkVersion rootProject.ext.compileSdkVersion
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        dexOptions {
            preDexLibraries false
            javaMaxHeapSize "4g"
        }
    
        defaultConfig {
    
            missingDimensionStrategy 'react-native-camera', 'general'
    
            applicationId "com.vakilsearch.crm"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            vectorDrawables.useSupportLibrary = true   
    
        }
        lintOptions {
            abortOnError false
            checkReleaseBuilds false
        }
        splits {
            abi {
                reset()
                enable enableSeparateBuildPerCPUArchitecture
                universalApk true  // If true, also generate a universal APK
    //            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
            }
        }
        signingConfigs {
            release {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
        buildTypes {
            release {
                signingConfig signingConfigs.release
    //            minifyEnabled enableProguardInReleaseBuilds
    //            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            }
            // dev is my added buildType
            dev {
                initWith release
                applicationIdSuffix ".dev"
                matchingFallbacks = ['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, "arm64-v8a": 3, "x86_64": 4]
                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
                }
            }
        }
    
        packagingOptions {
            exclude 'META-INF/services/javax.annotation.processing.Processor'
    
            pickFirst "lib/armeabi-v7a/libc++_shared.so"
            pickFirst "lib/arm64-v8a/libc++_shared.so"
            pickFirst "lib/x86/libc++_shared.so"
            pickFirst "lib/x86_64/libc++_shared.so"
        }
        // configurations {
        //     all { // You should exclude one of them for dublicate error
        //         exclude group: "com.google.android.a.a", module: "com.payu.gpay:payu-gpay:1.3.3"
        //     }
        // }
    } 
        dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
        //noinspection GradleDynamicVersion
        implementation "com.facebook.react:react-native:+"  // From node_modules
        implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
    
        debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
            exclude group: 'com.facebook.fbjni'
        }
    
        debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
            exclude group: 'com.facebook.flipper'
            exclude group:'com.squareup.okhttp3', module:'okhttp'
        }
    
        debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
            exclude group: 'com.facebook.flipper'
        }
        implementation 'com.google.firebase:firebase-appindexing:19.1.0'
        implementation 'com.google.firebase:firebase-core:17.5.1'
        implementation 'com.google.firebase:firebase-messaging:20.3.0'
        implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
        implementation 'com.google.android.gms:play-services-gcm:17.0.0'
        implementation 'com.google.android.gms:play-services-analytics:17.0.0'
    //    implementation 'com.google.android.gms:play-services-tagmanager:17.0.0'
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:support-v4:28.0.0'
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.annotation:annotation:1.1.0'
        implementation 'com.facebook.fresco:fresco:2.2.0'
        implementation 'com.facebook.fresco:animated-gif:2.0.0'
        // Firebase dependencies (INSERT THIS)
        //this overrides the sdk play services dependency, without the app crashes, because there can only be one version of google play services
        // implementation 'com.google.android.gms:play-services-base:17.1.0'
        //webengage
        implementation 'com.webengage:android-sdk:3.+'
    //    implementation 'com.google.android.gms:play-services-ads:19.1.0'
        implementation 'com.android.installreferrer:installreferrer:2.1'
        implementation 'com.payu.india:payu-checkout-pro:1.1.1' 
        if (enableHermes) {
            def hermesPath = "../../node_modules/hermes-engine/android/";
            debugImplementation files(hermesPath + "hermes-debug.aar")
            releaseImplementation files(hermesPath + "hermes-release.aar")
        } else {
            implementation jscFlavor
        }
    
    
    }

1 个答案:

答案 0 :(得分:0)

使用排除

implementation ('com.android.installreferrer:installreferrer:2.1'{
   exclude group: "com.google.android.a.b"
})

implementation ('com.payu.india:payu-checkout-pro:1.1.1'{
   exclude group: "com.google.android.a.c"
})