{"id":19765702,"url":"https://github.com/xuexiangjys/xupdateapi","last_synced_at":"2025-07-09T12:08:08.578Z","repository":{"id":101672895,"uuid":"323029958","full_name":"xuexiangjys/XUpdateAPI","owner":"xuexiangjys","description":"简化XUpdate的使用, 一键实现版本更新功能!","archived":false,"fork":false,"pushed_at":"2024-03-12T15:26:55.000Z","size":257,"stargazers_count":95,"open_issues_count":1,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-09T12:06:34.293Z","etag":null,"topics":["android","x-library","xupdate"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xuexiangjys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":"https://gitee.com/xuexiangjys/Resource/blob/master/doc/sponsor.md"}},"created_at":"2020-12-20T08:50:18.000Z","updated_at":"2025-04-15T08:10:01.000Z","dependencies_parsed_at":"2025-04-30T15:31:03.837Z","dependency_job_id":"ac1d9455-90e6-4ba5-b5fd-dccdc51382dc","html_url":"https://github.com/xuexiangjys/XUpdateAPI","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/xuexiangjys/XUpdateAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2FXUpdateAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2FXUpdateAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2FXUpdateAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2FXUpdateAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuexiangjys","download_url":"https://codeload.github.com/xuexiangjys/XUpdateAPI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuexiangjys%2FXUpdateAPI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264455988,"owners_count":23611065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","x-library","xupdate"],"created_at":"2024-11-12T04:19:11.017Z","updated_at":"2025-07-09T12:08:08.560Z","avatar_url":"https://github.com/xuexiangjys.png","language":"Java","funding_links":["https://gitee.com/xuexiangjys/Resource/blob/master/doc/sponsor.md"],"categories":[],"sub_categories":[],"readme":"# XUpdateAPI\n\n[![](https://jitpack.io/v/xuexiangjys/XUpdateAPI.svg)](https://jitpack.io/#xuexiangjys/XUpdateAPI)\n[![api](https://img.shields.io/badge/API-14+-brightgreen.svg)](https://android-arsenal.com/api?level=14)\n[![I](https://img.shields.io/github/issues/xuexiangjys/XUpdateAPI.svg)](https://github.com/xuexiangjys/XUpdateAPI/issues)\n[![Star](https://img.shields.io/github/stars/xuexiangjys/XUpdateAPI.svg)](https://github.com/xuexiangjys/XUpdateAPI)\n\n简化 [XUpdate](https://github.com/xuexiangjys/XUpdate) 的使用, 一键实现版本更新功能!\n\n## 关于我\n\n| 公众号   | 掘金     |  知乎    |  CSDN   |   简书   |   思否  |   哔哩哔哩  |   今日头条\n|---------|---------|--------- |---------|---------|---------|---------|---------|\n| [我的Android开源之旅](https://t.1yb.co/Irse)  |  [点我](https://juejin.im/user/598feef55188257d592e56ed/posts)    |   [点我](https://www.zhihu.com/people/xuexiangjys/posts)       |   [点我](https://xuexiangjys.blog.csdn.net/)  |   [点我](https://www.jianshu.com/u/6bf605575337)  |   [点我](https://segmentfault.com/u/xuexiangjys)  |   [点我](https://space.bilibili.com/483850585)  |   [点我](https://img.rruu.net/image/5ff34ff7b02dd)\n\n## 项目介绍\n\n为了方便大家更快地使用XUpdate，降低集成的难度，我编写了这个配套的拓展库。本库目前包含如下两部分内容：\n\n* EasyUpdate: 提供快速接入XUpdate的功能，无需初始化便可直接使用。\n\n* AriaDownloader: 提供断点续传下载的功能。\n\n## 集成指南\n\n### 添加Gradle依赖\n\n1.先在项目根目录的 build.gradle 的 repositories 添加:\n\n```\nallprojects {\n     repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\n2.然后在应用项目(一般是app)的 `build.gradle` 的 dependencies 添加:\n\n```\n   implementation 'com.github.xuexiangjys:XUpdate:2.1.2'\n   implementation 'com.github.xuexiangjys.XUpdateAPI:xupdate-easy:1.0.1'\n   // 如果需要使用断点续传下载功能的话添加该依赖（可选）\n   implementation 'com.github.xuexiangjys.XUpdateAPI:xupdate-downloader-aria:1.0.1'\n```\n\n3.自定义初始化配置（可选）\n\n因为本库采取了自动初始化的功能，因此你无需进行初始化，但是如果你需要自定义初始化配置的话，你可以实现`IUpdateConfigProvider`，并在`Application`的`attachBaseContext`前调用`EasyUpdate.setUpdateConfigProvider`方法设置自定义配置。\n\n```\n    @Override\n    protected void attachBaseContext(Context base) {\n        // 实现自定义配置\n        EasyUpdate.setUpdateConfigProvider(new CustomUpdateConfigProvider());\n        super.attachBaseContext(base);\n    }\n\n```\n\n4.开启断点续传下载功能（可选）\n\n* 方法一: 在自定义配置中设置下载代理\n\n```\nUpdateConfig.create()\n        // 开启断点续传下载功能\n        .setDownloadServiceProxy(new AriaDownloadServiceProxyImpl(context))\n```\n\n* 方法二: 使用`AriaDownloader.enable`开启\n\n```\nAriaDownloader.enable(this);\n```\n\n* 方法三: 使用`AriaDownloader.getUpdateHttpService`获取下载服务\n\n```\nEasyUpdate.create(getContext(), Constants.UPDATE_DEFAULT_URL)\n        .updateHttpService(AriaDownloader.getUpdateHttpService(getContext()))\n```\n\n***【注意】：在使用断点续传下载功能的时候，请务必设置md5值，否则将会导致升级异常。***\n\n## 注意事项\n\n需要注意的是，在使用`EasyUpdate`的时候，务必保证服务器返回的json格式应包括如下内容：\n\n```\n{\n  \"Code\": 0, //0代表请求成功，非0代表失败\n  \"Msg\": \"\", //请求出错的信息\n  \"UpdateStatus\": 1, //0代表不更新，1代表有版本更新，不需要强制升级，2代表有版本更新，需要强制升级\n  \"VersionCode\": 3,\n  \"VersionName\": \"1.0.2\",\n  \"ModifyContent\": \"1、优化api接口。\\r\\n2、添加使用demo演示。\\r\\n3、新增自定义更新服务API接口。\\r\\n4、优化更新提示界面。\",\n  \"DownloadUrl\": \"https://raw.githubusercontent.com/xuexiangjys/XUpdate/master/apk/xupdate_demo_1.0.2.apk\",\n  \"ApkSize\": 2048\n  \"ApkMd5\": \"...\"  //md5值没有的话，就无法保证apk是否完整，每次都会重新下载。\n}\n```\n\n如果你不想使用默认的json格式的话，可参考[XUpdate中如何自定义版本更新解析器](https://github.com/xuexiangjys/XUpdate/wiki/%E9%AB%98%E9%98%B6%E4%BD%BF%E7%94%A8#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%89%88%E6%9C%AC%E6%9B%B4%E6%96%B0%E8%A7%A3%E6%9E%90%E5%99%A8)\n\n## 使用方法\n\nEasyUpdate主要提供了如下两个方法:\n\n* EasyUpdate.create: 构建版本更新检查管理者\n\n* EasyUpdate.checkUpdate: 直接版本更新\n\n具体使用参见 [EasyUpdateFragment](https://github.com/xuexiangjys/XUpdateAPI/blob/master/app/src/main/java/com/xuexiang/xupdateapi/fragment/EasyUpdateFragment.java)。\n\n当然XUpdate的所有方法也都是支持的，具体可以参考[XUpdate的使用说明](https://github.com/xuexiangjys/XUpdate/wiki/%E5%9F%BA%E7%A1%80%E4%BD%BF%E7%94%A8).\n\n## 混淆配置\n\n* XUpdate\n\n```\n-keep class com.xuexiang.xupdate.entity.** { *; }\n\n//注意，如果你使用的是自定义Api解析器解析，还需要给你自定义Api实体配上混淆，如下是本demo中配置的自定义Api实体混淆规则：\n-keep class com.xuexiang.xupdatedemo.entity.** { *; }\n```\n\n* AriaDownloader\n\n```\n-dontwarn com.arialyy.aria.**\n-keep class com.arialyy.aria.**{*;}\n-keep class **$$DownloadListenerProxy{ *; }\n-keep class **$$UploadListenerProxy{ *; }\n-keep class **$$DownloadGroupListenerProxy{ *; }\n-keep class **$$DGSubListenerProxy{ *; }\n-keepclasseswithmembernames class * {\n    @Download.* \u003cmethods\u003e;\n    @Upload.* \u003cmethods\u003e;\n    @DownloadGroup.* \u003cmethods\u003e;\n}\n```\n\n## 配套设置\n\n* [XUpdate核心库](https://github.com/xuexiangjys/XUpdate)\n* [后台版本更新管理服务](https://github.com/xuexiangjys/XUpdateService)\n* [后台版本更新管理系统](https://github.com/xuexiangjys/xupdate-management)\n* [Flutter插件](https://github.com/xuexiangjys/flutter_xupdate)\n* [React-Native插件](https://github.com/xuexiangjys/react-native-xupdate)\n\n## 如果觉得项目还不错，可以考虑打赏一波\n\n\u003e 你的打赏是我维护的动力，我将会列出所有打赏人员的清单在下方作为凭证，打赏前请留下打赏项目的备注！\n\n![pay.png](https://raw.githubusercontent.com/xuexiangjys/Resource/master/img/pay/pay.png)\n\n## 联系方式\n\n\u003e 更多资讯内容，欢迎扫描关注我的个人微信公众号:【我的Android开源之旅】\n\n![](https://s1.ax1x.com/2022/04/27/LbGMJH.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuexiangjys%2Fxupdateapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuexiangjys%2Fxupdateapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuexiangjys%2Fxupdateapi/lists"}