【问题标题】:React native build failed Execution failed for task ':app:checkDebugDuplicateClasses'反应本机构建失败任务':app:checkDebugDuplicateClasses'的执行失败
【发布时间】:2020-10-27 11:43:19
【问题描述】:

使用 installreferrerpayu sdk.iam new to react native 尝试集成 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)```

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

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

【问题讨论】:

  • 那个错误是因为你双链接原生sdk。你手动链接对吗?你需要摆脱这种变化,因为如果你使用 rn >0.60 它会为你做到这一点
  • 你说的原生sdk是什么意思
  • payumobile.gitbook.io/sdk-integration/react-native/… 你有反应原生链接 payu-non-seam-less-react 吗?如果你这样做了并且你的版本是>60,它会检索你那个异常
  • @anthonywillismuñoz 我没有运行这个命令 react-native link payu-non-seam-less-react
  • 实现 ('com.android.installreferrer:installreferrer:2.1', { exclude group: 'google', module: 'android.a.b', })

标签: java android reactjs react-native mobile


【解决方案1】:

使用排除

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 并收到相同的错误
猜你喜欢
  • 2019-10-05
  • 2021-08-11
  • 2022-10-20
  • 2018-03-27
  • 2020-07-16
  • 1970-01-01
  • 1970-01-01
  • 2022-12-13
  • 2021-10-09
相关资源
最近更新 更多