DEV Community

Cover image for Update Your Android App When You Release an APK on GitHub (Using a Library)
Sumanth Perambuduri
Sumanth Perambuduri

Posted on • Edited on

Update Your Android App When You Release an APK on GitHub (Using a Library)

GitHub logo 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 release APK files with every new GitHub release, APKUpdater-Library can make updating your app seamless.

Requirements

  • Version Consistency Your Gradle versionName and GitHub release tag version must match. Adding a v prefix in GitHub is optional.

Gradle:

versionName "X.Y"
or
versionName "X.Y.Z"
Enter fullscreen mode Exit fullscreen mode

GitHub Release Tag:

vX.Y or X.Y
or
vX.Y.Z or X.Y.Z
Enter fullscreen mode Exit fullscreen mode
  • Add JitPack repository In your top-level build.gradle:
allprojects {
    repositories {
        /// ....
        maven { url "https://jitpack.io" }
    }
}
Enter fullscreen mode Exit fullscreen mode
  • Add the library dependency In your module-level build.gradle:
implementation 'com.github.supersu-man:apkupdater-library:v2.1.0'
Enter fullscreen mode Exit fullscreen mode

Usage

  • Initialize the Updater
val url = "https://github.com/supersu-man/macronium-android/releases/latest"
val updater = ApkUpdater(this@MainActivity, url)
Enter fullscreen mode Exit fullscreen mode
  • Check for update
updater.isNewUpdateAvailable {
    //Your code when new update is found in the repo
}
Enter fullscreen mode Exit fullscreen mode

Example

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)
}
Enter fullscreen mode Exit fullscreen mode
private fun checkForUpdates(updater: ApkUpdater) {
    if (updater.isNewUpdateAvailable() == true) {
        updater.requestDownload()
    }
}
Enter fullscreen mode Exit fullscreen mode

Recommended Read 📖

If you’d like to understand the complete process of building, signing, and releasing Android apps on GitHub using GitHub Actions, I highly recommend reading my earlier post first — it covers all the fundamentals before we dive into using secrets:
Building, Signing and Releasing Android Apps with GitHub Actions

Top comments (2)

Collapse
 
gafireb64 profile image
gafireb

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.

Collapse
 
frraqw22 profile image
sg sfds

Lucky Win 777 often includes daily bonuses, free spins, and special events that reward players just for logging in or playing consistently Download here. These features allow users to enjoy extended gameplay without necessarily spending money. This reward system keeps players motivated and adds an element of anticipation, making the game more engaging over time.