A small update checker for Android apps. You host one JSON file anywhere (GitHub, your server, S3). The library reads it, compares the version with the installed app, and can show a ready-made update dialog, or just hand you the data.
- You host the JSON: no Play Services, no update SDK.
- Built-in dialog: shows the new version and what's new, and follows your app's theme in light and dark mode.
- Forced updates: set
"cancellable": falseand the dialog has no "Later" button. - Or build your own UI: get the parsed data and the whole JSON in a callback.
- Tiny: a few small classes, written in Kotlin, works from Java too. Min SDK 21.
| Light | Dark |
|---|---|
![]() |
![]() |
- Add JitPack in
settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}- Add the dependency:
dependencies {
implementation("com.github.p32929:AndroidAppUpdater:2.0.0")
}{
"versionCode": 2,
"cancellable": true,
"url": "https://play.google.com/store/apps/details?id=your.app",
"versionName": "2.0.0",
"changelog": "1. A fresh new look\n2. Bug fixes"
}versionCode(required): the version code of the newest release.cancellable(required):falseforces the user to update.url(required): where the Update button takes the user, like Google Play or a download page.versionNameandchangelog(optional): shown in the built-in dialog.- Any other fields you add are passed to you in the callback.
There is a working example in docs/sample-update.json.
Call this in your activity, for example in onCreate. It shows the dialog only when a newer version is out.
Kotlin:
AppUpdater.check(this, "https://example.com/update.json")Java:
AppUpdater.check(this, "https://example.com/update.json");The activity must use an AppCompat or Material theme. With a Material 3 theme the dialog looks like Material 3.
Kotlin:
AppUpdater(this, jsonUrl, object : UpdateListener {
override fun onJsonDataReceived(updateModel: UpdateModel, jsonObject: JSONObject) {
if (updateModel.isNewerThanInstalled(this@MainActivity)) {
// Show your own UI, or the built-in one:
AppUpdater.showDialog(this@MainActivity, updateModel)
}
}
override fun onError(error: String) {
// No internet, bad URL or bad JSON
}
}).execute()Java:
new AppUpdater(this, jsonUrl, new UpdateListener() {
@Override
public void onJsonDataReceived(UpdateModel updateModel, JSONObject jsonObject) {
if (updateModel.isNewerThanInstalled(MainActivity.this)) {
AppUpdater.showDialog(MainActivity.this, updateModel);
}
}
@Override
public void onError(String error) {
}
}).execute();Callbacks run on the main thread. They are skipped if the activity is already closing.
Most code keeps working. new AppUpdater(context, url, listener).execute(), UpdateListener, UpdateModel.getVersionCode(), isCancellable(), getUrl() and AppUpdater.getCurrentVersionCode(context) are all the same.
- Change the dependency to
com.github.p32929:AndroidAppUpdater:2.0.0and use the JitPack line above. AppUpdateris no longer anAsyncTask, socancel()andexecuteOnExecutor()are gone. Just callexecute().- The library no longer checks the network first, so the "Please check your network connection" error is gone. Network problems now come to
onErrorwith the real reason. - The
ACCESS_NETWORK_STATEpermission is no longer added to your app. - Your old JSON files work as they are.
MIT License — Copyright (c) 2019 Fayaz Bin Salam. See LICENSE for the full text.
Contributions are very welcome, thank you! Before you start on a pull request, please open an issue and tell me what you would like to add or change. That way we can agree on it first, and your time is not wasted on something that might not fit. Thanks for helping make AndroidAppUpdater better.

