I'm applying CodePush to React Native I'm getting a build error on the Android side when finalizing the application. I would appreciate it if you could take a look
Error Message
> Task :app:mergeReleaseResources FAILED
ERROR:[string/CodePushDeploymentKey] /Users/up/Desktop/project/coinpickle-app/android/app/src/main/res/values/strings.xml [string/CodePushDeploymentKey] /Users/up/Desktop/project/coinpickle-app/android/app/build/generated/res/resValues/release/values/gradleResValues.xml: Resource and asset merger: Duplicate resources
Probable Cause I have code overlap in my CodePush setup
Mycode
1. strings.xml
<resources>
<string name="app_name">XXXXXX</string>
<string moduleConfig="true" name="CodePushDeploymentKey">XXXXXX</string> // Duplicate code here
</resources>
2. gradleResValues.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Automatically generated file. DO NOT MODIFY -->
<!-- Value from build type: debug -->
<string name="CODE_PUSH_APK_BUILD_TIME" translatable="false">"1697169479092"</string>
<!-- Value from build type: debug -->
<string name="CodePushDeploymentKey" translatable="false"></string> // Duplicate code here
<!-- Value from default config. -->
<integer name="react_native_dev_server_port">8081</integer>
<!-- Value from default config. -->
<integer name="react_native_inspector_proxy_port">8081</integer>
</resources>
app/build.gradle
buildTypes {
debug {
signingConfig signingConfigs.debug
resValue "string", "CodePushDeploymentKey", CODEPUSH_DEPLOYMENT_KEY_DEBUG
}
releaseStaging {
initWith release
resValue "string", "CodePushDeploymentKey", CODEPUSH_DEPLOYMENT_KEY_STAGING
matchingFallbacks = ['release']
}
release {
resValue "string", "CodePushDeploymentKey", CODEPUSH_DEPLOYMENT_KEY_PRODUCTION
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
Tried
- Modify the configuration file
- Delete duplicate code from sgrings.xml (another error occurs when deleting: R does not exit)
- rebuild and build clean all
Desired Why duplicate code happens and how to fix it safely
I need help from experts and those who have encountered the error, please. ㅠ-ㅠ
Its happen due to your java version. you can downgrade to java 11. it works for me