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

Android - Fix Drawable v4 paths in Android Artifact Resources (Libraries) #13128

Closed
wants to merge 11 commits into from
19 changes: 19 additions & 0 deletions react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void runBefore(String dependentTaskName, Task task) {
}

afterEvaluate {
def isAndroidLibrary = plugins.hasPlugin("com.android.library")
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type -> type.name }
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
Expand Down Expand Up @@ -101,6 +102,24 @@ afterEvaluate {
enabled config."bundleIn${targetName}" ||
config."bundleIn${buildTypeName.capitalize()}" ?:
targetName.toLowerCase().contains("release")

if (isAndroidLibrary) {
doLast {
def moveFunc = { resSuffix ->
File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
if (originalDir.exists()) {
File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
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()
}
}
}

// Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
Expand Down