I am using Google Play Billing subscriptions in a Flutter app with the in_app_purchase package.
Subscriptions work correctly when the app is installed from Google Play Internal Testing.
However, purchases fail when the same app is installed locally using:
flutter run
Android Studio
manually installed APK
Purchase error:
The item that you were attempting to purchase could not be found
App installed from Google Play Internal Testing
Same tester Gmail account
Same subscription products
Purchase flow works correctly
Same app installed locally
queryProductDetails() successfully returns products
purchase flow fails with item not found error
applicationId matches Play Console package name
subscription IDs are correct
subscriptions and base plans are active
tester account is added in License Testing
same Gmail account is used on device
I also signed debug/release builds using the same upload keystore:
signingConfigs {
getByName("debug") {
storeFile = file("upload-keystore.jks")
storePassword = "xxx"
keyAlias = "xxx"
keyPassword = "xxx"
}
create("release") {
storeFile = file("upload-keystore.jks")
storePassword = "xxx"
keyAlias = "xxx"
keyPassword = "xxx"
}
}
But purchases still fail for locally installed APKs.
Why does Google Play Billing allow purchases only for the Play Store Internal Testing install but not for locally installed debug/release APKs, even when package name, subscription IDs, and signing key all match?
This is expected behaiviorfrom google play biling, not a Flutter or signing issue.
queryProductDetails() succeeding does not meam purchases are allowed.
The key distiction is:
Product queryng -> can work from locally installed builds
Real purchase flow -> generally requires the app to be installed theough Google Play
For subscriptions and in-app products, Google Play Billing validates more than:
package name
singing certificate
productIDs
tester account
It also validates install source / Play owership metadata
When you install via:
flutter run
Android Studio
adb install
manually opening APK
the app is not recognized as a play-managed install, so Billing may reject purcgases with errors like:
> The item that you were attempting to purchase could not be found
That message is misleading - the product exists, but the installation sontext is not eligible.
Why Internal Testing works:
installed from Play Store
Play injects billing metadata
entitlement and purchase verefivation chain is valid
Why singing with upload key doesn't help:
updolad/app singing keys prove isenty
they do not make sideloaded APKs equinalent to Play-distrivuted installs
Recommended testing approaches:
Upload build to Internal Testing
Install inly nia Play Store
Increment versionCode for updates
Remove previous sideloaded copies before installing from Play
Wait serval minutes after pulishing subscription/base-plan changes
For loval sevelopment:
mock purchases
abstract billing behind an interface
use Play-distributed builds for end-to-end purchase test
So the behavior you see is normal: Google Play Billing purchase testing is sipported from Play-installed buids, not arbitray locally installed APKs