After upgrading to React Native 0.57 i am facing an issue when genrating APK in react-native-router-flux.when executing the .\gradlew assembleRelease i get below error :-
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> [drawable-mdpi-v4/node_modules_reactnativerouterflux_images_back_chevron]
R:\Workings\lisecapps\androidrepo\test-react-
native\venutest\android\app\src\main\res\drawable-
mdpi\node_modules_reactnativerouterflux_images_back_chevron.png
[drawable-mdpi-v4/node_modules_reactnativerouterflux_images_back_chevron]
R:\Workings\lisecapps\androidrepo\test-react-
emirnative\venutest\android\app\build\generated\res\react\release\drawable-
mdpi-v4\node_modules_reactnativerouterflux_images_back_chevron.png: Error:
Duplicate resources
[drawable-mdpi-v4/node_modules_reactnativerouterflux_images_menu_burger]
R:\Workings\lisecapps\androidrepo\test-react-nat
ive\venutest\android\app\src\main\res\drawable-
mdpi\node_modules_reactnativerouterflux_images_menu_burger.png
[drawable-mdpi-v4/node_modules_reactnativerouterflux_images_menu_burger]
R:\Workings\lisecapps\androidrepo\test-react-
native\venutest\android\app\build\generated\res\react\release\drawable-mdpi-
v4\node_modules_reactnativerouterflux_images_menu_burger.png: Error:
Duplicate resources
I tried the following to resolve but still same error :-
It seems like you have the same image resource in two files OR you added an additional, non-required file to the res folder. Rename or remove the other. You can check the required structure of the res folder and subfolders by downloading a fresh copy of WebViewGold from CodeCanyon.
You need remove generated resources/drawable and generate again.
rm -rf android/app/src/main/res/drawable-*
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
And compile android again react-native run-android
react.gradle automatically build your javascript and copy any resources imported inside your javascript to the build folder so make sure to NOT call react-native bundle
manually and delete any files or folder as src/main/res/drawable-*
and src/main/assets/*.bundle
and have the following changes into your app/bundle.gradle
project.ext.react = [
entryFile : "index.js", // or index.android.js
bundleInRelease: true,
bundleInDebug: true
]
apply from: "../../node_modules/react-native/react.gradle"
Note: please notice that some react-native versions have a problem with the local cli.js
please make sure to upgrade to a newer version or try adding the following config
project.ext.react = [
// ...
cliPath: "node_modules/react-native/local-cli/cli.js"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With