Skip to content

Commit

Permalink
Add ugly workaround to make the sample project work with AGP 7.3 😬
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Nov 15, 2022
1 parent b2a523d commit 4f759e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
26 changes: 23 additions & 3 deletions sample/example-vector/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.api.variant.ResValue
import com.android.build.api.AndroidPluginVersion
import kotlin.Pair

apply plugin: 'com.starter.application.android'
Expand Down Expand Up @@ -58,10 +59,29 @@ android {
}
}


androidComponents {
onVariants(selector().withFlavor(new Pair("reportedBugs", "usingResValues"))) { variant ->
def value = new ResValue(variant.applicationId.get(), "Covers https://github.com/usefulness/easylauncher-gradle-plugin/issues/382")
variant.resValues.put(variant.makeResValueKey("string", "generated_key"), value)
if (pluginVersion < new AndroidPluginVersion(7, 4).beta(1)) {
tasks.register("agpHasBugs") {
def resourcesFile = file("src/usingResValues/res/values/generated_strings.xml")

doLast {
resourcesFile.parentFile.mkdirs()
resourcesFile.write("""
<resources>
<string name="generated_key">New AGP apis are broken</string>
</resources>
""")
}
}
tasks.withType(com.android.build.gradle.tasks.GenerateResValues).configureEach {
dependsOn("agpHasBugs")
}
} else {
onVariants(selector().withFlavor(new Pair("reportedBugs", "usingResValues"))) { variant ->
def value = new ResValue(variant.applicationId.get(), "Covers https://github.com/usefulness/easylauncher-gradle-plugin/issues/382")
variant.resValues.put(variant.makeResValueKey("string", "generated_key"), value)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions sample/example-vector/src/usingResValues/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
generated_strings.xml

0 comments on commit 4f759e4

Please sign in to comment.