-
-
Notifications
You must be signed in to change notification settings - Fork 411
如何引用
xuexiangjys edited this page Mar 21, 2019
·
30 revisions
1.先在项目根目录的 build.gradle 的 repositories 添加:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
2.然后在dependencies添加:
dependencies {
...
implementation 'com.github.xuexiangjys:XUpdate:1.0.6'
}
3.在Application进行初始化配置:
【注意】这里需要注意的是,IUpdateHttpService
必须设置,否则框架将无法正常使用!IUpdateHttpService
的实现可参照Demo中的实现
XUpdate.get()
.debug(true) //开启debug模式,可用于问题的排查
.isWifiOnly(true) //默认设置只在wifi下检查版本更新
.isGet(true) //默认设置使用get请求检查版本
.isAutoMode(false) //默认设置非自动模式,可根据具体使用配置
.param("VersionCode", UpdateUtils.getVersionCode(this)) //设置默认公共请求参数
.param("AppKey", getPackageName())
.setOnUpdateFailureListener(new OnUpdateFailureListener() { //设置版本更新出错的监听
@Override
public void onFailure(UpdateError error) {
ToastUtils.toast(error.toString());
}
})
.setIUpdateHttpService(new OKHttpUpdateHttpService()) //这个必须设置!实现网络请求功能。
.init(this); //这个必须初始化
【注意】:如果出现任何问题,可开启debug模式来追踪问题。如果你还需要将日志记录在磁盘上,可实现以下接口
XUpdate.get().setILogger(new ILogger() {
@Override
public void log(int priority, String tag, String message, Throwable t) {
//实现日志记录功能
}
});
-keep class com.xuexiang.xupdate.entity.** { *; }