payu-intrepos / payu-non-seamless-react

Non-Seamless SDK for React Native
5 stars 9 forks source link

react native payu-non-seamless-react implementation recieves error Execution failed for task ':app:checkDebugDuplicateClasses'. #2

Closed ikmofem7 closed 3 years ago

ikmofem7 commented 3 years ago

working with installreferrer and payu sdk. i am new to react native tried to integrate payumobile for payment integration recieve error Execution failed for task ':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()
        }
    }`

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

apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

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'
    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}`

"react": "^16.13.1",
"react-native": "^0.63.2",
"payu-non-seam-less-react": "^2.0.0",
sachinxagrawal commented 3 years ago

update version of com.payu.gpay:payu-gpay:1.3.5 under dependencies in payu-non-seamless-react build.gradle

himgupta229 commented 3 years ago

Kindly update the sdk to 2.1.0.

ikmofem7 commented 3 years ago

@himgupta229 implementation 'com.payu.india:payu-checkout-pro:2.1.0' do u mean like this

himgupta229 commented 3 years ago

No, update the react module

ikmofem7 commented 3 years ago

in my package.json i have added version "payu-non-seam-less-react": "^2.0.0", do i need to update here

himgupta229 commented 3 years ago

You have to download the latest version via npm.

ikmofem7 commented 3 years ago

ok ill try that

mohamed-ikram commented 3 years ago

hello i have upgraded the "payu-non-seam-less-react": "^2.1.0", the above errors are fixed but still getting duplicate error from com.payu.upisdk:upisdk:1.3.0


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class a.a.a.a.a found in modules jetified-app-1.4.2-react-runtime.jar (com.smartlook.recording:app:1.4.2-react) and jetified-upisdk-1.3.0-runtime.jar (com.payu.upisdk:upisdk:1.3.0)````

**thanks for ur support**
can u help me to fix this
mohamed-ikram commented 3 years ago

i have fixed this by adding implementation 'com.payu.upisdk:upisdk:1.3.1' in android/app/build.gradle