Closed kuba007 closed 3 years ago
I think AGP changed the way things are ordered which means the plugin incorrectly gets run before everything else. As a workaround, you should be able to do this:
plugins {
id '...' apply false
}
build logic here
apply plugin: '...'
Thanks for advice. However, I tried it without any success. The only workaround for me is to set application ID in defaults and run publish tasks one by one (not really handy).
Tried to downgrade to version 2.8.0 where the suggested late applying work for me!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm going to close this in favor of #864 since I need to figure out the ordering issues.
Understand, thank you that you are dealing this issue (even under different ticket :))
@SUPERCILEX
I read through the linked tickets but if I understand it correctly you closed the other issues without solving this reordering problem, correct? Is there a known workaround with 3.4.0 for AGP 4.1.x? Is it worth reopening this ticket to have it as reference again as the problem is not yet solved?
Pretty much: I don't know of any gradle or AGP APIs to handle ordering. That said, is something still broken for you? This issue shouldn't occur.
Yes, we set applicationId
and applicationIdSuffix
like this in the android
block:
applicationVariants.all {
if (flavorName == "playStoreVariant") {
(mergedFlavor as com.android.build.gradle.internal.core.MergedFlavor).apply {
applicationId = Config.Application.applicationId
applicationIdSuffix = ""
}
}
}
So AGPs suffix handling adds a suffix here, but we want to remove it and set it to "". GPP still picks up the suffix though.
This is already a workaround though because the default AGP handling for suffixes doesn't match our requirements. This works though for all the builds, but GPP plugin is picking up the applicationId
before this block is executed (apparently).
Another workaround would be if we could explicitly set the applicationId
GPP should use instead of letting it figure it out automatically. This would work for us, because we only have one flavor that's uploaded. But I don't see a way to set the id explicitly, right?
Thinking about it, the order might not be the problem. Could also be that GPP looks up the applicationId
somewhere else and not at the final merged flavors?
Oh but you're using internal AGP APIs so all bets are off at that point. If you're on GPP 3.4 though, you should be able to use the new AGP variant APIs:
androidComponents.onVariants { variant ->
variant.applicationId.set("foo")
}
These should be picked up by GPP just fine (I think).
That said, if you only have one flavor, why are things so complicated? Is there a reason you can't default to no suffix and then only add it where necessary?
Yes, we use the internal API - we already figured it will bite us at some point but it worked so far 😄
We will take a peak at your suggestion - would be awesome to have a proper solution. Thanks for the hint.
We only have one play store flavor currently but a couple of other distribution targets which unfortunately require this setup.
So I switched to the onVariants
method and it works correctly for our builds, but GPP still picks up the old ID (when running bootstrap
task) set before in defaultConfig
and productFlavor
(suffix
):
android {
onVariants {
onProperties {
applicationId.set("new.app.id")
}
}
}
Darn, I created #948. I don't have time to look at it right now, but I need to create some tests for the new variant api.
Having a multiple-dimension product flavors, I do "calculate" the applicationId by code like this one:
However, when I run the publish task, I am getting error from Publishing API that "Package not found: cz.james.xxx" whereas cz.james.xxx is the value from /main/AndroidManifest.xml overriden during the build by code above.
Before, I was using version 2.2.0 with p12 auth working fine with this setup. Now, after upgrading to 3.0.0 (and the JSON auth style) it is broken (even tried 3.1.0-SNAPSHOT).
Any help or fix appreciated.