r/androiddev • u/Hornet-Mountain • Aug 25 '26
Experience Exchange How I do paid licensing for an app that has no network permission, and the one thing that bit me
Sharing this because when I searched for it I mostly found "just use a licensing server", which is no help if you deliberately ship with no INTERNET permission.
The shape that ended up working: when someone buys, a small server-side function signs a short payload (a version tag, the order id, and an update-window bound) with an RSA private key. The buyer gets that string by email and pastes it into the app. The app verifies it against a public key compiled into the APK. No network call ever happens on the device, the private key never leaves the server, and the APK only ever contains the public key so pulling it apart gets you nothing.
The thing I got wrong first: I gated on the device clock. "Valid until 2027" as a date is trivially beaten by rolling the clock back, and you can't phone home to check. So instead I compare the bound baked into the license against the build date compiled into the APK. Both are independent of the device clock, so changing the clock does nothing. Old license plus old build keeps working, old license plus a newer build is what triggers the renew path.
One compatibility note that cost me an afternoon: if you sign on the server with Web Crypto (RSASSA-PKCS1-v1_5 + SHA-256) and verify on the JVM with Signature "SHA256withRSA", those are the same algorithm and interoperate byte for byte. The two things that silently break it are the key format (the signer wanted PKCS#8, not PKCS#1) and base64url vs standard base64 on the token. Once those matched, a signature made in one stack verified in the other and in openssl, which is the check I'd recommend before you ship anything.
It is not piracy proof and I'm not pretending it is. Someone can patch the verify call. The point was making it painless for people who want to pay, not stopping the ones who won't.
The part I still don't love is the update entitlement offline. Comparing against build date works but it's coarse. Curious how others have handled "you paid, you get updates until X" without a server.

