Droidup - Simple, flexible app self-updater for Android

Overview

🌐 English | 中文

DroidUp

Simple, flexible app self-updater for Android.

Workflow JitPack License


Features

  • Simple: Out-of box self-update process within ~500L of code

  • Flexible: Decoupled handlers to easily replace

  • Kotlin-ism: The fastest droidUp {} builder to configure update within seconds

Installation

AAR

Download

Gradle

JitPack

// Root build.gradle (/build.gradle)
allprojects {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}

// Module build.gradle (/app/build.gradle)
dependencies {
    implementation 'com.ilharper:droidup:latest.version.here'
    // Or use snapshot
    // implementation 'com.ilharper:droidup:master-SNAPSHOT'
}

Usage

Quick Setup

Run this after your MainActivity loaded:

droidUp {
    useSimpleChecker("https://my.app/releases")
}.check()

That's it! DroidUp will automatically fetch the update info in background thread, prompt user to get the update when there's new version available, download and verify the apk file and finally install the new app.

Flow & Handlers

DroidUp calls the following handlers in order:

1. checker

var checker: (DroidUpContext) -> DroidUpInfo

checker is for handling version checking, and useSimpleChecker() is the default checker implementation.

First, put a latest.json file like this on your static site (e.g. https://my.app/releases/latest.json):

{
    "version": 8, // versionCode
    "url": "./app-8.apk", // Can be relative or absolute
    "hash": "YVbrfcHla+8RriE+h2qIMavqIq/s0noO8mpIHerDHHxBYRVEgWrVV96CGSx9GbHYCUKw2EMIiCLVsvyjWtshFw==", // SHA512 by default
    "size": 60294047, // long
    "releaseNote": "Add new features" // Will be displayed in UpdatePrompt dialog
}

We provide droidup-gen to automatically generate latest.json from apk file.

Then, useSimpleChecker() to set update source:

  droidUp {
+     useSimpleChecker("https://my.app/releases")
  }

The URL will be resolved to https://my.app/releases/app-8.apk.

If you want to check updates using encrypted API, or you have other needs, just implement the checker yourself, and then

  droidUp {
+     checker = myCustomChecker
  }

2. comparator

var comparator: (DroidUpContext) -> Boolean

comparator is used to determine whether the remote version is newer. useSimpleComparator() is the default comparator implementation, you don't need to call it manually.

useSimpleComparator() emits update only when DroidUpInfo.version > current version.

Use custom comparator:

  droidUp {
+     comparator = myCustomComparator
  }

3. prompter

var prompter: (DroidUpContext, () -> Unit) -> Unit

prompter is for popping update dialog. useSimplePrompter() is the default prompter implementation, you don't need to call it manually.

useSimplePrompter() uses AlertDialog.

Use custom prompter for customizing dialog:

  droidUp {
+     prompter = myCustomPrompter
  }

4. downloader

var downloader: (DroidUpContext, (File) -> Unit) -> Unit

downloader is for downloading the new apk file. useSimpleDownloader() is the default downloader implementation, you don't need to call it manually. It shows a notification with progress when downloading.

Use custom downloader to use your own download service:

  droidUp {
+     downloader = myCustomDownloader
  }

5. verifier

var verifier: (DroidUpContext) -> Boolean

verifier is for checking the hash of the downloaded apk file. useSimpleVerifier() is the default verifier implementation, you don't need to call it manually. It uses base64 encoded SHA-512 hash string.

Use custom verifier:

  droidUp {
+     verifier = myCustomVerifier
  }

6. installer

var installer: (DroidUpContext) -> Unit

installer is for installing app. useSimpleInstaller() is the default installer implementation, you don't need to call it manually.

Use custom installer if you want to install apk automatically using ROOT privileges, or you have other needs:

  droidUp {
+     installer = myCustomInstaller
  }

Advanced

Singleton

It's recommended to use the DroidUp.default singleton:

DroidUp.default = (DroidUp.default ?: (droidUp {
    useSimpleChecker("https://my.app/releases")
})).check()

This way, DroidUp instance won't be created multiple times.

Manual Check

Use check(true) to show toast when processing:

droidUp {
    useSimpleChecker("https://my.app/releases")
}.check(true)

Explicitly Specify Activity

DroidUp.check() automatically uses the current activity by default. Use check(activity) to explicitly specify activity:

droidUp {
    useSimpleChecker("https://my.app/releases")
}.check(activity)

Bugs & Issues

Feel free to open issues.

Contributions

PRs are welcome! Feel free to contribute on this project.

Changelog

See releases

LICENSE

MIT

You might also like...
A very simple Android app which shows you random memes with the help of meme-api which you can share with your friends!
A very simple Android app which shows you random memes with the help of meme-api which you can share with your friends!

Meme Share A very simple Android app which shows you random memes with the help of meme-api which you can share with your friends! Tech stack 100% wri

Simple Note App With MVVM Clean Architecture
Simple Note App With MVVM Clean Architecture

NoteWakeup Simple Note App With MVVM Clean Architecture ✍🏽 Simple Note App. Here i demonstrate the use of Modern Android development tools - (Kotlin,

Simple App made for a test to Studio Sol Company

Studio Sol Test - Guess the Number Simple App made for a test to Studio Sol Company. #What you'll see in this project: ViewBinding Navigation Animatio

LinkHub is a simple and effective link management application that can help you to easily manage your app with no ads!
LinkHub is a simple and effective link management application that can help you to easily manage your app with no ads!

LinkHub LinkHub is a simple and effective link management application that can help you to easily manage your own links with no ads! Download Screensh

A simple App which fetches data from NewYork times api and show news to the user
A simple App which fetches data from NewYork times api and show news to the user

Stay-TheNewsApp This is a simple java app, which fetches data from NewYork times api and show news to the user, News can be seen from various categori

A simple ToDo Task Manager App made in Kotlin using Room DataBase.
A simple ToDo Task Manager App made in Kotlin using Room DataBase.

ToDo List App 🌟 About A simple To-Do List Management App that helps you get things done. Built with Kotlin, it helps the user to add their task. User

AppD-Task1 - A simple basic app with use of card view and toast
AppD-Task1 - A simple basic app with use of card view and toast

AppD-Task1 Made a simple basic app with use of card view and toast. Screenshots

LoginValidation - A simple login app with password validation
LoginValidation - A simple login app with password validation

LoginValidation A simple login app with password validation License Copyright 20

Edorva-assessment - A simple drawing app for Edorva's Assessment

Edorva Assessment app A simple drawing app for Edorva's Assessment Note: The app

Releases(0.1.5)
Owner
IlHarper Infrastructure.
null
A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Dario Mungoi 7 Sep 17, 2022
Flexible switch is a responsive switch with some nice features which developers can use for making awesome switches on android platform.

flexible-switch It is a responsive switch in android, it can resize itself according to its size. It's recommended to use it with ConstraintLayout to

Coders Route 5 Dec 20, 2022
Tictactoe-android-app - Simple TicTacToe Android app written in Kotlin

TicTacToe Android App This is a simple example of TicTacToe game as Android app

Blaž Čerpnjak 1 Jul 9, 2022
A simple karaoke app. My first Android project.

Chorus This is my first Android project ever. I'm very happy that I managed to start it. Thanks a lot to the devs, who made all of the software I'm us

Ilya 1 Jan 18, 2022
A sample code taking picture in android with app permission and simple ui

Android Taking Picture Sample Just sample code taking picture in android with ap

M. Hafizh Anbiya 2 Dec 29, 2021
DrawingApp - A simple drawing app for Android, built using Kotlin

DrawingApp This is a simple drawing app for Android, built using Kotlin. How It'

null 0 Dec 12, 2021
DSU-Sideloader - A simple app made to help users easily install GSIs via DSU's Android feature

DSU Sideloader A simple app made to help users easily install GSIs via DSU's And

null 430 Jan 4, 2023
LoginApp - A simple android login app where the username can be shared

LoginApp A simple android login app where the username can be shared. License Co

Srihitha Tadiparthi 2 Feb 14, 2022
DiceRoller - A simple android dice roller app

DiceRoller A simple android dice roller app License Copyright 2022 Srihitha Tadi

Srihitha Tadiparthi 1 Feb 11, 2022
Simple FOSS android app to help you plan and manage your savings goals easily and establish the habit of saving money.

GreenStash GreenStash is a simple FOSS android app to help you plan and manage your savings goals easily and establish the habit of saving money. ?? S

Pool-Of-Tears 112 Dec 3, 2022