mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 17:33:15 +08:00
Summary:
If `$buildDir/generated/res/react/${flavorPathSegment}release/raw` contains files during `gradle assembleRelease` script will fail with `Error: Duplicate resources` error.
This patch is based on this issue [22234](https://github.com/facebook/react-native/issues/22234) and pull request [24518](https://github.com/facebook/react-native/pull/24518).
[Android] [Fixed] - Fix duplicate resource error for raw folder in Android build
[CC from Mike Hardy PR]
Reports of success on the linked issue via use of the patch + patch-package for a couple months, I personally use it full time with all gradle builds (./gradlew clean assembleRelease or if you have a 'staging' flavor, e.g. ./gradlew clean assembleStagingRelease)
Related reading, also cross-links with the linked issue here:
https://stackoverflow.com/questions/53239705/react-native-error-duplicate-resources-android
Pull Request resolved: https://github.com/facebook/react-native/pull/24778
Differential Revision: D15277766
Pulled By: cpojer
fbshipit-source-id: 0ccd76d2aa2e13f7c8bfac07d4ef23b74945807a
This commit is contained in:
committed by
Facebook Github Bot
parent
962437fafd
commit
eb534bca58
17
react.gradle
17
react.gradle
@@ -60,18 +60,19 @@ afterEvaluate {
|
||||
// Address issue #22234 by moving generated resources into build dir so they are in one spot, not duplicated
|
||||
doLast {
|
||||
def moveFunc = { resSuffix ->
|
||||
File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
|
||||
File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${resSuffix}")
|
||||
if (originalDir.exists()) {
|
||||
File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
|
||||
File destDir = file("$buildDir/../src/main/res/${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()
|
||||
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()
|
||||
}
|
||||
|
||||
// Set up inputs and outputs so gradle can cache the result
|
||||
|
||||
Reference in New Issue
Block a user