upgrade-support
upgrade-support copied to clipboard
Duplicate Resources error while generating release APK (Migrating from 0.59.5 to 0.61.5)
Environment
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 140.81 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries: Node: 14.4.0 - /var/folders/vb/yvc825yd15ldmskwnwtrpsnjdgvdj0/T/yarn--1596208558025-0.4815624974976791/node Yarn: 1.19.0 - /var/folders/vb/yvc825yd15ldmskwnwtrpsnjdgvdj0/T/yarn--1596208558025-0.4815624974976791/yarn npm: 6.14.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0 Android SDK: API Levels: 28, 29 Build Tools: 27.0.3, 28.0.3, 29.0.1, 29.0.2 System Images: android-19 | Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-21 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: 11.1/11A1027 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: react-native-cli: 2.0.1
Upgrading version
From 0.59.5 to 0.61.5
Description
Duplicate Resources error while generating release APK
Upgraded react-from 0.59.5 to 0.61.5 version. After upgrade tried to generate release APK for the application but build failed with an exception stating duplicate resources for the assets. Tried a workaround by updating the below code in react.gradle file.
```
doLast {
def moveFunc = { resSuffix ->
File originalDir = file("$buildDir/generated/res/react/release/${resSuffix}");
if (originalDir.exists()) {
File destDir = file("$buildDir/../src/main/res/${resSuffix}");
ant.move(file: originalDir, tofile: destDir);
}
}
moveFunc.curry("drawable-ldpi").call()
moveFunc.curry("drawable-mdpi").call()
moveFunc.curry("drawable-hdpi").call()
moveFunc.curry("drawable-xhdpi").call()
moveFunc.curry("drawable-xxhdpi").call()
moveFunc.curry("drawable-xxxhdpi").call()
moveFunc.curry("raw").call()
}
Now after the above workaround we are able to generate release APK successfully but in the generated APK none of the images are present since they get removed but we need to use those images.
## Reproducible demo
Run ./gradlew assembleRelease to get this error.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> [drawable-mdpi-v4/toasset] /path/toasset.png