supersu-man / apkupdater-library
Checks for the latest release in the GitHub repo and if latest apk release is found, it downloads the apk for you.
If you also release APK file with every new release as an asset on GitHub just like me, this could be a very useful Library to you.
Requirements
- Your App Version name in Gradle and your release Tag version on GitHub needs to be SAME (adding 'v' is optional in GitHub Tag version).
Gradle:
versionName "X.Y"
GitHub Tag version for release:
vX.Y or X.Y
- 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:GitHubAPKUpdater-Library:v1.6'
Usage
Usage in one of my Apps here
Simple implementation here
Example
thread {
val updater = Updater(this, "Link_to_your_repo")
checkForUpdates(updater)
}
private fun checkForUpdates(updater: Updater) {
if (updater.isInternetConnection()){
updater.init()
updater.isNewUpdateAvailable {
if (updater.hasPermissionsGranted()){
updater.requestDownload()
} else{
updater.requestMyPermissions {
updater.requestDownload()
}
}
}
}
}
Explanation
- Initializing (use your repo link like this)
val updater = Updater(this,"https://github.com/supersu-man/Macronium/releases/latest")
- Checking for required Permissions
updater.hasPermissionsGranted()
- Requesting required permissions (it's WRITE_EXTERNAL_STORAGE here)
updater.requestMyPermissions {
//Your code after user gives the permission
}
- Checking for Internet Connection
updater.isInternetConnection()
- Checking for New Update (if the version name and latest tag version don't match it detects as new update)
updater.init()
updater.isNewUpdateAvailable {
//Your code when new update is found in the repo
}
- Download latest APK
updater.requestDownload()
Top comments (1)
To
Upload the APK: Go to your GitHub repository, create a new release, and attach the APK file.
Update Library: Adjust your project’s visit website library dependencies if needed (e.g., update version numbers in Gradle).
Publish Release: Complete the release process and notify users of the update.