This repository was archived by the owner on May 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
This repository was archived by the owner on May 20, 2025. It is now read-only.
ReactNative with code-push AOS build [Error : Duplicate resources] #2596
Copy link
Copy link
Closed
Description
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
Version
"react-native-code-push": "^8.1.0",
"react-native": "0.71.10",
"appcenter": "^5.0.0",
dependencies {
classpath('com.android.tools.build:gradle:7.3.1')
classpath("com.facebook.react:react-native-gradle-plugin")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
Desired
Why duplicate code happens and how to fix it safely
I need help from experts and those who have encountered the error, please. ㅠ-ㅠ
Metadata
Metadata
Assignees
Labels
No labels