Triple-T / gradle-play-publisher

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
MIT License
4.1k stars 340 forks source link

Including the WearOS build in the release track #1026

Closed sjaakiejj closed 2 years ago

sjaakiejj commented 2 years ago

What are you having trouble with and how can we help you? I've been using Gradle Play Publisher to publish my Android app for some time now and I've recently added a dependent WearOS companion app.

My build.gradle looks as follows:

Android App:

apply plugin: "com.android.application"
apply plugin: "com.github.triplet.play"

...
defaultConfig {
        applicationId "com.myapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode (getVersionCodeString() + "00").toInteger()
        versionName getVersionName()
        missingDimensionStrategy 'store', 'play'
    }
}

android {
  applicationVariants.all { variant ->
        if ( variant.buildType.name == "release"){
            tasks.getByName("publishBundle") {
                dependsOn tasks.named("processReleaseVersionCodes")
                play {
                    resolutionStrategy.set(com.github.triplet.gradle.androidpublisher.ResolutionStrategy.AUTO)
                }
            }
        }
   }
}
...
dependencies {
   ...
    wearApp project(':wearos')
}

WearOS App:

apply plugin: "com.android.application"
apply plugin: "com.github.triplet.play"

...
defaultConfig {
        applicationId "com.myapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode (getVersionCodeString() + "01").toInteger()
        versionName getVersionName()
        missingDimensionStrategy 'store', 'play'
    }
}

android {
  applicationVariants.all { variant ->
        if ( variant.buildType.name == "release"){
            tasks.getByName("publishBundle") {
                dependsOn tasks.named("processReleaseVersionCodes")
                play {
                    resolutionStrategy.set(com.github.triplet.gradle.androidpublisher.ResolutionStrategy.AUTO)
                }
            }
        }
   }
}

When running this, both the Android app and the WearOS app get uploaded to Google Play. The Android app will have a version code 68000 and the WearOS app will have a version code 68001.

Gradle Play Publisher then automatically assigns the Android app as a new release in the 'Internal Testing' track, but this release does not include the WearOS APK. I can manually go into the Play console to then create a new release that includes both, after which the release is correctly available on both WearOS and Android, but I can't figure out how to get Gradle Play Publisher to do this for me.

To my understanding, product flavours aren't meant for this use case, and I've tried making use of retain but that results in the following error

org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method listOf() for arguments [61601] on extension 'play' property 'retain' of type com.github.triplet.gradle.play.PlayPublisherExtension$Retain.
SUPERCILEX commented 2 years ago

Please delete the applicationVariants stuff and only keep the play block, a top level play block with AUTO resolution should work just fine. Or if you were trying to only configure release variants, use playConfigs.

I believe the version codes for the watch and phone apks are supposed to be different: https://developer.android.com/training/wearables/packaging#specify-a-version-code. You can then follow this guide: https://github.com/Triple-T/gradle-play-publisher#combining-artifacts-into-a-single-release. For your case, you have seperate build files so I think that means you'll have to pick one Gradle module to do the commit and then lock in that ordering by adding the mustRunAfter logic inside the root build file.

github-actions[bot] commented 2 years ago

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.

damiafuentes commented 2 years ago

@sjaakiejj What did you end up doing? If you solved it, can you provide the needed code to upload the wear and mobile app to internal testing at the same time?