Skip to content

Commit 8b1b579

Browse files
authored
[in_app_purchase_android] Update to Play Billing Library 9.1.0 (flutter#12781)
Updates `com.android.billingclient:billing` from 8.0.0 to 9.1.0 in `in_app_purchase_android`. **Why the minSdk change is required.** Play Billing Library 9 declares `minSdkVersion 23` in its own AAR manifest (8.0.0 declared 21). With the plugin still on `minSdk = 21`, the manifest merger fails in any consuming app: ``` Manifest merger failed : uses-sdk:minSdkVersion 21 cannot be smaller than version 23 declared in library [com.android.billingclient:billing:9.1.0] ``` The library module itself still builds at 21, so this only surfaces in the app that consumes the plugin. Raising the plugin's `minSdk` to 23 makes the constraint explicit. Flutter's own `flutter.minSdkVersion` is already 24, so there is no practical impact on clients. The same floor is imposed a second time transitively, via `play-services-basement` 18.9.0. **No removed APIs are used.** Diffing the public API of `billing-8.0.0.aar` against `billing-9.1.0.aar` shows v9 removes exactly seven classes — `SkuDetails`, `SkuDetailsParams(.Builder)`, `SkuDetailsResponseListener`, `BillingClient.SkuType`, `QueryPurchaseHistoryParams(.Builder)` — plus `BillingFlowParams.Builder.setSkuDetailsList`. None appear anywhere under `android/src`. `PurchaseHistoryRecord`, which `Translator.kt` still imports, survives into 9.1.0. **Deprecation.** `SubscriptionUpdateParams.Builder.setSubscriptionReplacementMode` is deprecated as of 8.1.0 but remains functional in 9.x. Because the example builds the plugin with `-Xlint:all -Werror`, this breaks the build, so it is suppressed with an explanatory comment rather than migrated. Migrating to `SubscriptionProductReplacementParams` is not a drop-in change: it renumbered the replacement mode constants, which would alter the values carried by the Dart `ReplacementMode` enum. That belongs in its own breaking change. **Behaviour change reaching clients.** Under v9, a Play Store blocked by the system (for example OEM-customized kids mode) reports `BILLING_UNAVAILABLE` instead of `ERROR`. The plugin maps response codes 1:1 and branches on neither value, so no plugin code changes; but apps that branch on the code, or match on the stringified code in `IAPError.message`, are affected. This is called out in the CHANGELOG. Also corrects the documentation for `BillingResponse.billingUnavailable` (described the legacy "billing API version not supported" meaning) and `BillingResponse.serviceUnavailable` (described a network outage, which is what `networkError` means). This supersedes flutter#12414, the Dependabot version-only bump, which does not include the required `minSdk` change and therefore does not build. ## Testing Automated: all existing Dart and native unit tests pass against 9.1.0, and the example app builds. Manual, against a real Play Console app running this branch with billing 9.1.0: - product queries (`queryProductDetails`) return the expected products, prices and offers - restoring past purchases works Not exercised manually: the subscription replacement path (`setSubscriptionReplacementMode`), which is the deprecated call suppressed in this PR, and consumable purchase/consumption. Flagging that explicitly since it is the least-covered part of this change — note also that the plugin's unit tests mock `BillingClient` entirely, so none of them exercise the real library at runtime. Fixes flutter/flutter#189974 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. **Test exemption:** this is a manual dependency roll, which Tree Hygiene lists as *not* automatically exempt, so I am requesting one explicitly. The plugin's behaviour is unchanged: response codes are passed through 1:1 (`Translator.kt` -> pigeon -> `pigeon_converters.dart`), and no branch in the plugin keys on `error` or `billingUnavailable`. The one user-visible change originates in Google's library, not in plugin code, and so cannot be exercised by a plugin test. Happy to add tests if a reviewer sees a seam I have missed. **On the deprecation suppression:** if the team would rather take the breaking `SubscriptionProductReplacementParams` migration now instead of suppressing, I am glad to do that here or in a follow-up — say which you prefer. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 1c44dbf commit 8b1b579

6 files changed

Lines changed: 36 additions & 6 deletions

File tree

‎packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 0.5.5
2+
3+
* Updates Google Play Billing Library from 8.0.0 to 9.1.0.
4+
* Raises the minimum supported Android SDK version to 23, as required by Google
5+
Play Billing Library 9. Apps targeting a lower `minSdkVersion` will fail to
6+
merge the manifest; Flutter's own minimum is already 24.
7+
* **Behaviour change:** when the Play Store app is blocked by the system (for
8+
example, in OEM-customized kids mode), Google Play Billing Library 9 reports
9+
`BillingResponse.billingUnavailable` where it previously reported
10+
`BillingResponse.error`. Apps that branch on the response code, or that match
11+
on the stringified code in `IAPError.message`, must handle the new value.
12+
* Corrects the documentation for `BillingResponse.billingUnavailable` and
13+
`BillingResponse.serviceUnavailable`, which described the wrong conditions.
14+
115
## 0.5.4
216

317
* Fixes a crash (`IllegalStateException: Reply already submitted`) when the

‎packages/in_app_purchase/in_app_purchase_android/android/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ android {
4141
compileSdk = flutter.compileSdkVersion
4242

4343
defaultConfig {
44-
minSdk = 21
44+
minSdk = 23
4545
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4646
}
4747

@@ -86,7 +86,7 @@ android {
8686

8787
dependencies {
8888
implementation("androidx.annotation:annotation:1.10.0")
89-
implementation("com.android.billingclient:billing:8.0.0")
89+
implementation("com.android.billingclient:billing:9.1.0")
9090
testImplementation("junit:junit:4.13.2")
9191
testImplementation("org.json:json:20251224")
9292
testImplementation("org.mockito:mockito-core:5.23.0")

‎packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ public void queryProductDetailsAsync(
282282
}
283283
}
284284

285+
// SubscriptionUpdateParams.Builder.setSubscriptionReplacementMode is deprecated as of Google
286+
// Play Billing Library 8.1.0 in favour of SubscriptionProductReplacementParams, but remains
287+
// functional in 9.x. Migrating is not a drop-in change: the replacement mode constants were
288+
// renumbered, so it would alter the values carried by the Dart ReplacementMode enum.
289+
// TODO(gmackall): migrate to setSubscriptionProductReplacementParams as a
290+
// separate breaking change. https://github.com/flutter/flutter/issues/194324
291+
@SuppressWarnings("deprecation")
285292
@Override
286293
public @NonNull PlatformBillingResult launchBillingFlow(
287294
@NonNull PlatformBillingFlowParams params) {

‎packages/in_app_purchase/in_app_purchase_android/example/android/app/build.gradle.kts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ flutter {
9797
}
9898

9999
dependencies {
100-
implementation("com.android.billingclient:billing:6.1.0")
100+
implementation("com.android.billingclient:billing:9.1.0")
101101
testImplementation("junit:junit:4.13.2")
102102
testImplementation("org.mockito:mockito-core:5.1.1")
103103
testImplementation("org.json:json:20260814")

‎packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/billing_client_wrapper.dart‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,19 @@ enum BillingResponse {
380380
/// The user pressed back or canceled a dialog.
381381
userCanceled,
382382

383-
/// The network connection is down.
383+
/// The service is currently unavailable.
384+
///
385+
/// This is a transient state; the request can be retried later. Note that
386+
/// Play no longer returns [BillingResponse.serviceTimeout], and timeouts are
387+
/// reported here instead.
384388
serviceUnavailable,
385389

386-
/// The billing API version is not supported for the type requested.
390+
/// A user billing error occurred during processing.
391+
///
392+
/// As of Google Play Billing Library 9, this is also returned when the Play
393+
/// Store app is blocked by the system (for example, in OEM-customized kids
394+
/// mode), a case that previously surfaced as [BillingResponse.error]. Such
395+
/// results carry a `Play Store is blocked` debug message.
387396
billingUnavailable,
388397

389398
/// The requested product is not available for purchase.

‎packages/in_app_purchase/in_app_purchase_android/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: An implementation for the Android platform of the Flutter `in_app_p
33
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
55

6-
version: 0.5.4
6+
version: 0.5.5
77

88
environment:
99
sdk: ^3.12.0

0 commit comments

Comments
 (0)