Haripriya Dhall
Haripriya Dhall

Reputation: 1

Duplicate class com.facebook.proguard.annotations.KeepGettersAndSetters - Gradle build failes

I am getting the below error while running the app.

Duplicate class com.facebook.proguard.annotations.KeepGettersAndSetters found in modules conceal-2.0.2.aar -> jetified-conceal-2.0.2-runtime (com.facebook.conceal:conceal:2.0.2) and react-android-0.74.4-debug.aar -> jetified-react-android-0.74.4-debug-runtime (com.facebook.react:react-android:0.74.4)

Here is my app/build.gradle file

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

import com.android.build.OutputFile

react {
 
def enableSeparateBuildPerCPUArchitecture = false


def enableProguardInReleaseBuilds = false


def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Private function to get the list of Native Architectures you want to build.
 * This reads the value from reactNativeArchitectures in your gradle.properties
 * file and works together with the --active-arch-only flag of react-native run-android.
 */
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    ndkVersion rootProject.ext.ndkVersion

    //compileSdkVersion rootProject.ext.compileSdkVersion
    compileSdkVersion rootProject.ext.compileSdkVersion
    //buildToolsVersion = "34.0.0"

    namespace "com.xyz"
    defaultConfig {
        applicationId "com.xyz"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 109
        versionName "1.9.40"
        missingDimensionStrategy 'react-native-camera', 'general'
            multiDexEnabled true

    }
    packagingOptions {
        exclude 'com/facebook/proguard/annotations/KeepGettersAndSetters.class'
    }

configurations {
    all*.exclude module: 'fbjni-java-only'

}
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'xxxx'
            keyAlias 'androiddebug'
            keyPassword 'xxxxxx'
        }
        release {
//             storeFile file('PS_Android_Key_Store')
//             storePassword 'xxxxx'
//             keyAlias 'xxxx'
//             keyPassword 'xxxxx'

            storeFile file('reitogo_Certificate.p14')
            storePassword 'xxxx'
            keyAlias 'xxx'
            keyPassword 'xxxxx'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }


    flavorDimensions = ["app"]

    productFlavors {
        abc {
            dimension "app"
            manifestPlaceholders = [transistorsoftKey:"1xxxx", googleMapsKey:"2xxxx"]
        }

        def {
            dimension "app"
            applicationId 'com.def2'
            resValue "string", "build_config_package", "com.abc"
            manifestPlaceholders = [transistorsoftKey:"xxx", googleMapsKey:"xxxx"]
        }
    }

    // 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:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
            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 =
                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
            }

        }
    }
}
configurations.all {
    resolutionStrategy.force 'com.facebook.conceal:conceal:2.0.2'
        exclude group: 'com.facebook.fbjni'
        exclude group: 'com.facebook.yoga'
        exclude group: 'com.facebook.soloader'

}


dependencies {
    implementation ('com.facebook.react:react-android')
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
    implementation 'com.android.support:multidex:2.0.1'
    //implementation ("com.facebook.conceal:conceal:2.0.2@aar")
    implementation 'com.facebook.conceal:conceal:2.0.2' exclude group: 'com.facebook.proguard.annotations'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

i tried to solve by adding this but it is not working.

exclude group: 'com.facebook.proguard.annotations'

Upvotes: 0

Views: 24

Answers (0)

Related Questions