Fixed version code not found exception while publishing bundle on play store

This commit is contained in:
MohitMali 2023-10-17 15:13:09 +05:30
parent 71f851821a
commit 53d4ac1847
2 changed files with 5 additions and 14 deletions

View File

@ -120,12 +120,12 @@ class Transaction(
}).execute().prettyPrint()
@Suppress("DEPRECATION")
fun addBundleToTrackInDraft(versionCode: Int, versionName: String?): Track =
fun addBundleToTrackInDraft(versionCode: Int?, versionName: String?): Track =
publisher.edits().tracks().update(packageName, editId, "internal", Track().apply {
releases = listOf(TrackRelease().apply {
status = "draft"
name = versionName
versionCodes = listOf(versionCode.toLong())
versionCodes = listOf(versionCode?.toLong())
})
track = "internal"
}).execute().prettyPrint()

View File

@ -36,7 +36,7 @@ android {
}
File("$projectDir/../install_time_asset_for_dwds/src/main/assets", "$name.zim").let {
createDownloadTaskForPlayAssetDelivery(it)
createPublishBundleWithAssetPlayDelivery(applicationVariants)
createPublishBundleWithAssetPlayDelivery()
}
}
}
@ -48,11 +48,6 @@ android {
enableSplit = false
}
}
splits {
abi {
isUniversalApk = true
}
}
assetPacks += ":install_time_asset_for_dwds"
}
@ -192,9 +187,7 @@ fun DomainObjectSet<ApplicationVariant>.releaseVariantsFor(productFlavor: Produc
find { it.name.equals("${productFlavor.name}Release", true) }!!
.outputs.filterIsInstance<ApkVariantOutput>().sortedBy { it.versionCodeOverride }
fun ProductFlavor.createPublishBundleWithAssetPlayDelivery(
applicationVariants: DomainObjectSet<ApplicationVariant>
): Task {
fun ProductFlavor.createPublishBundleWithAssetPlayDelivery(): Task {
val capitalizedName =
name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else "$it" }
return tasks.create("publish${capitalizedName}ReleaseBundleWithPlayAssetDelivery") {
@ -205,8 +198,6 @@ fun ProductFlavor.createPublishBundleWithAssetPlayDelivery(
println("packageName $packageName")
createPublisher(File(rootDir, "playstore.json"))
.transactionWithCommit(packageName) {
val variants =
applicationVariants.releaseVariantsFor(this@createPublishBundleWithAssetPlayDelivery)
val generatedBundleFile =
File(
"$buildDir/outputs/bundle/${capitalizedName.lowercase(Locale.getDefault())}" +
@ -214,7 +205,7 @@ fun ProductFlavor.createPublishBundleWithAssetPlayDelivery(
)
if (generatedBundleFile.exists()) {
uploadBundle(generatedBundleFile)
addBundleToTrackInDraft(variants[0].versionCode, versionName)
addBundleToTrackInDraft(versionCode, versionName)
} else {
throw FileNotFoundException("Unable to find generated aab file")
}