Checks for the latest release in your GitHub repo. Downloads latest apk if new release is found.
If you also release APK files with every new release on GitHub just like me, this could be a very useful Library.
- Your App Version name in Gradle and your release Tag version on GitHub needs to be SAME (adding 'v' is optional in github tag).
Gradle:
versionName "X.Y"
or
versionName "X.Y.Z"
GitHub Tag for release:
vX.Y or X.Y
or
vX.Y.Z or X.Y.Z
- Add these lines in top level build.gradle
allprojects {
repositories {
/// ....
maven { url "https://jitpack.io" }
}
}
- Add this line in build.gradle
implementation 'com.github.supersu-man:apkupdater-library:v2.1.0'
Simple implementation here
thread {
val url = "https://github.com/supersu-man/macronium-android/releases/latest"
val updater = ApkUpdater(this@MainActivity, url)
updater.threeNumbers = false //if versioning is X.Y
updater.threeNumbers = true //if versioning is X.Y.Z
checkForUpdates(updater)
}
private fun checkForUpdates(updater: ApkUpdater) {
if (updater.isNewUpdateAvailable() == true) {
updater.requestDownload()
}
}
- Initializing (use your repo link like this)
val updater = ApkUpdater(this@MainActivity, url)
- Checking for new update (if the versionName and latest tag don't match it detects as new update)
updater.isNewUpdateAvailable {
//Your code when new update is found in the repo
}
- Download latest apk
updater.requestDownload()