Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.zuohailong:appupdate:0.2.6'
}
dependencies {
implementation("com.github.zuohailong:appupdate:0.2.6")
}
<dependency>
<groupId>com.github.zuohailong</groupId>
<artifactId>appupdate</artifactId>
<version>0.2.6</version>
</dependency>
libraryDependencies += "com.github.zuohailong" % "appupdate" % "0.2.6"
:dependencies [[com.github.zuohailong/appupdate "0.2.6"]]

支持指向apk文件的 url 形式的版本更新
支持指向接口、接口返回二进制文件流的 url 形式的版本更新
支持断点下载
采用 Service + AsyncTask 方式下载
提供界面友好的版本更新提示弹窗,可自定义其主题样式
兼容Android 6.0,更新库自动获取写权限,用户拒绝后可再次请求
兼容Android 7.0,支持FileProvider
兼容Android 8.0,应用安装无障碍
实现国际化(支持中文和英文)
dependencies {
implementation 'com.github.ZuoHailong:AppUpdate:0.2.6'
}
AppUpdateManager.Builder builder = new AppUpdateManager.Builder(MainActivity.this);
builder.apkUrl(String apkUrl)
.updateContent(String[] array)
.updateForce(boolean isForce)
.build();
builder.apkUrl(String apkUrl)
builder.apkUrl(String[] array)
builder.updateForce(boolean isForce)
builder.newVerName(String newVerName)
builder.title(String title)
builder.confirmText(String confirmText)
builder.cancelText(String cancelText)
builder.apkContentLength(long apkContentLength)
builder.breakpoint(boolean breakpoint)
builder.build()
builder.topResId(@DrawableRes int topResId)
builder.confirmBgColor(@ColorInt int color)
builder.confirmBgResource(@DrawableRes int resid)
builder.cancelBgColor(@ColorInt int color)
builder.cancelBgResource(@DrawableRes int resid)
builder.progressDrawable(@DrawableRes int resid)