React Native Android Duplicate file error when generating apk

后端 未结 8 1461
生来不讨喜
生来不讨喜 2020-11-30 20:30

When I am trying to generate android apk by using ./gradlew installRelease, I get this error in console:

~/React-Native/mockingbird/android/app/         


        
相关标签:
8条回答
  • 2020-11-30 21:23

    For me it work to remove the folder: android/build and run ./gradlew assembleRelease again.

    0 讨论(0)
  • 2020-11-30 21:29

    In order to get my build working for React Native 0.57.5, I used Mapsy's answer with a minor enhancement. I needed to be able to build for multiple flavors and generally I try to avoid hardcoding things. When looking through my react.gradle file, I found it had the following variable defined:

    def resourcesDir = file("$buildDir/generated/res/react/${targetPath}")
    

    So instead of hardcoding the build type/flavor in the path like this:

    File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
    

    I instead used the resourcesDir variable to set the originalDir path like this:

    File originalDir = file("${resourcesDir}/drawable-${resSuffix}");
    

    As a result, my doLast looks like this:

    doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("${resourcesDir}/drawable-${resSuffix}");
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                        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()
            }
    
    0 讨论(0)
提交回复
热议问题