allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.gypnick:updateapk:V1.1'
}
UpdateService.Builder.create(url) //url为下载apk的地址
.setVersionCode(2) //这里设置服务器上的版本,通过这里来和本地versionCode版本对比
.setIsForce(true) //是否强制更新,强制更新用户不更新就强制退出APP
.build(MainActivity.this);
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path path="Android/data/你的包名/" name="files_root" />
<external-path path="." name="external_storage_root" />
</paths>