facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.34k stars 24.23k forks source link

VERSION_NAME is already defined in class BuildConfig #35650

Closed arihantop closed 1 year ago

arihantop commented 1 year ago

Description

node_modules/payu-non-seam-less-react/android/build/generated/source/buildConfig/debug/com/payubiz/BuildConfig.java:13:

error: variable VERSION_NAME is already defined in class BuildConfig public static final String VERSION_NAME = "2.5.0";

Version

0.63.5

Output of npx react-native info

System: OS: macOS 12.5 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 244.79 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 8.17.0 - ~/.nvm/versions/node/v8.17.0/bin/node Yarn: Not Found npm: 6.14.10 - ~/Desktop/Work/RNMobileApp/node_modules/.bin/npm Watchman: 2022.12.12.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 13.0/13A233 - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /usr/bin/javac Python: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: ^0.63.5 => 0.63.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

npx react-native run-android

Snack, code example, screenshot, or link to a repository

node_modules/payu-non-seam-less-react/android/build/generated/source/buildConfig/debug/com/payubiz/BuildConfig.java:13:

error: variable VERSION_NAME is already defined in class BuildConfig public static final String VERSION_NAME = "2.5.0";

cortinico commented 1 year ago

you probably have buildConfigField setting VERSION_NAME in your android/app/build.gradle that is creating this.

Can you share your android/app/build.gradle file?

arihantop commented 1 year ago

def useIntlJsc = false apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' //apply plugin: "io.fabric"

import com.android.build.OutputFile

/**

project.ext.react = [ entryFile: "index.js", jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/out", enableHermes: false, // clean and rebuild if changing hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes", nodeExecutableAndArgs : ["/usr/local/bin/node"] ]

apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

/**

/**

/**

/**

android { compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.halaplay"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    multiDexEnabled true
    versionCode 41
    versionName "32.1"
    ndk {
        abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
dexOptions { 
    javaMaxHeapSize "4g" 
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
    release {
        storeFile file("./halaplay-release-key.keystore")
        storePassword "567890"
        keyAlias "halaplay-release-key-alias"
        keyPassword "567890"
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        multiDexEnabled true
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

// 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
        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
        }

    }
}

}

dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) compile project(':react-native-splash-screen') //noinspection GradleDynamicVersion implementation 'com.google.firebase:firebase-core:17.5.1' implementation 'com.google.firebase:firebase-analytics' implementation "com.google.firebase:firebase-dynamic-links:21.0.2" implementation "com.google.firebase:firebase-invites:17.0.0" implementation platform('com.google.firebase:firebase-bom:30.4.1') implementation 'phonepe.intentsdk.android.release:IntentSDK:1.6.7' implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0' implementation 'com.android.support:multidex:2.0.1' implementation "com.google.firebase:firebase-messaging"

// implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
//     transitive = true
// }

implementation 'com.google.firebase:firebase-firestore'
implementation 'com.firebaseui:firebase-ui-auth:6.4.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

implementation 'com.android.support:support-v13:26.0.2'

implementation project(path: ":PayWithAmazon", configuration: 'default')
implementation project(path: ':HP_LB', configuration: 'default')

// implementation project(path: ":NG_LB", configuration: 'default')

// implementation 'com.payumoney.sdkui:plug-n-play:1.6.0'

implementation project(':react-native-moengage')
//implementation project(path: ':react-native-fbsdk-next', configuration: 'default')
implementation("com.moengage:moe-android-sdk:11.6.02")
implementation("androidx.core:core:1.3.1")
implementation("androidx.appcompat:appcompat:1.2.0")
implementation("androidx.lifecycle:lifecycle-process:2.2.0")
implementation("com.moengage:rich-notification:2.4.0")
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
implementation('com.paytm:pgplussdk:1.4.4') {
    transitive = true;
}

 implementation('org.simpleframework:simple-xml:2.7.1') {
    exclude module: 'stax-api'
    exclude module: 'stax'
    exclude module: 'xpp3'
}

implementation 'com.google.android.material:material:1.1.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.github.d-max:spots-dialog:1.1@aar'
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'com.koushikdutta.async:androidasync:2.+'
implementation 'org.apache.commons:commons-lang3:3.5'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.douglasjunior:android-simple-tooltip:0.2.3'
implementation 'com.github.warkiz.widget:indicatorseekbar:2.1.2'

implementation "com.android.support:appcompat-v7:23.0.1"
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'com.firebaseui:firebase-ui-database:5.0.0'

implementation "com.squareup.okhttp3:okhttp"
implementation "com.squareup.okhttp3:okhttp-bom:4.4.1"

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'
}

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}
if (useIntlJsc) {
    implementation 'org.webkit:android-jsc-intl:+'
} else {
    implementation 'org.webkit:android-jsc:+'
}

}

// Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' }

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

apply plugin: 'com.google.gms.google-services'

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

arihantop commented 1 year ago

this the buildCofing.java file its an auto generated file

/**

public final class BuildConfig { public static final boolean DEBUG = Boolean.parseBoolean("true"); public static final String LIBRARY_PACKAGE_NAME = "com.payubiz"; public static final String BUILD_TYPE = "debug"; public static final int VERSION_CODE = 1; public static final String VERSION_NAME = "2.5.0"; // Fields from default config. public static final String VERSION_NAME = "2.5.0"; }

arihantop commented 1 year ago

change this line : buildConfigField "String", "VERSION_NAME", "\"$versionName\""

to: buildConfigField "String", "APP_VERSION_NAME", "\"$versionName\""

under node_modules of payu-seam-less-react in build.gradle file.