Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Duplicate resources - Failed to generate Signed APK in Android studio #1097

Closed
ajitdas123 opened this issue Nov 15, 2019 · 10 comments
Closed

Comments

@ajitdas123
Copy link

A similar issue has been raised before for IOS #1074

Environment

OS: Android
React native: 0.60.5
react-native-vector-icons: 6.6.0

Description

When I was trying to generate signed APK with Android Studio, I am getting duplicate resource error.
Error log:

[raw/node_modules_reactnativevectoricons_glyphmaps_feather] /Users/ad/Documents/react-native-project/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_feather.json [raw/node_modules_reactnativevectoricons_glyphmaps_feather] /Users/ad/Documents/react-native-project/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_feather.json: Error: Duplicate resources
[raw/app] /Users/ad/Documents/react-native-project/android/app/src/main/res/raw/app.json [raw/app] /Users/ad/Documents/react-native-project/android/app/build/generated/res/react/release/raw/app.json: Error: Duplicate resources
[raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome] /Users/ad/Documents/react-native-project/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome.json [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome] /Users/ad/Documents/react-native-project/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome.json: Error: Duplicate resources
[raw/node_modules_reactnativevectoricons_glyphmaps_zocial] /Users/ad/Documents/react-native-project/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_zocial.json [raw/node_modules_reactnativevectoricons_glyphmaps_zocial] /Users/ad/Documents/react-native-project/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_zocial.json: Error: Duplicate resources
[raw/node_modules_reactnativevectoricons_glyphmaps_entypo] /Users/ad/Documents/react-native-project/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_entypo.json [raw/node_modules_reactnativevectoricons_glyphmaps_entypo] /Users/ad/Documents/react-native-project/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_entypo.json: Error: Duplicate resources

Can anyone please tell me how can I resolve this.

@owaisbakhtiar
Copy link

Did someone faced and resolved this issue? :(

@wgltony
Copy link

wgltony commented Dec 18, 2019

Same issue,

OS: Android
React native: 0.60.0
react-native-vector-icons: 6.6.0

@wilfred888111
Copy link

I have faced similar issue yesterday. Removing the raw folder from
/Users/ad/Documents/react-native-project/android/app/src/main/res/ worked for me!

@gie3d
Copy link

gie3d commented Feb 3, 2020

This might help facebook/react-native#22234 (comment).

add this into node_modules/react-native/react.gradle file

def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }

                moveFunc.curry("ldpi").call()
                moveFunc.curry("mdpi").call()
                moveFunc.curry("hdpi").call()
                moveFunc.curry("xhdpi").call()
                moveFunc.curry("xxhdpi").call()
                moveFunc.curry("xxxhdpi").call()
                moveRawFunc.curry("raw").call()
            }

@Buwaneka-Sumanasekara
Copy link

After delete {your_project}/android/app/src/main/res/raw worked.

@ironmanromeo
Copy link

After delete {your_project}/android/app/src/main/res/raw worked.

Thank you so much! It worked.

@rahulshyokand
Copy link

I have faced similar issue yesterday. Removing the raw folder from
/Users/ad/Documents/react-native-project/android/app/src/main/res/ worked for me!

Worked !! Thanks

@juandelcano
Copy link

After delete {your_project}/android/app/src/main/res/raw worked.

thank you for saving my life ...

@venomkage
Copy link

I have faced similar issue yesterday. Removing the raw folder from /Users/ad/Documents/react-native-project/android/app/src/main/res/ worked for me!

This one worked for me! Thanks

@yourerrorbro
Copy link

I hope this email finds you well. I wanted to share an informative blog post with you that I recently came across. Here i provide proper solution. In above example i check. Initially worked but when build upload that's time create issue.
https://medium.com/@yourerrorbro/handling-duplicate-resource-issue-in-android-released-builds-in-react-native-f63c67176bce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests