簡體   English   中英

反應本機構建失敗任務':app:checkDebugDuplicateClasses'的執行失敗

[英]React native build failed Execution failed for task ':app:checkDebugDuplicateClasses'

使用installreferrerpayu sdk.iam new 來響應原生嘗試集成 payumobile 以進行支付集成收到錯誤任務“:app:checkDebugDuplicateClasses”執行失敗。

``` FAILURE:構建失敗並出現異常。

*  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)```

安卓/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()
        }
    } 

我在 app 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
        }
    
    
    }

使用排除

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

確保在gradle.properties文件中啟用並提到了androidXJetifier支持。 如果沒有,請將以下條目添加到gradle.properties文件中。

android.useAndroidX=true
android.enableJetifier=true

如果在添加上述行后仍然出現相同的錯誤,則可能是因為node_modules中的包沖突。

因此,嘗試完全刪除node_modules文件夾並使用npm install再次安裝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM