czy1121 / update

清晰灵活简单易用的应用更新库

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

更新安装包下载完成后总是提示“下载失败:检验错误”,但是MD5是没错的

Jorble opened this issue · comments

`/**
* 检查更新
*/
private void checkUpdate() {
UpdateUtil.clean(getContext());//清除sp的忽略标志和apk文件缓存
UpdateManager.setDebuggable(true);
UpdateManager.setWifiOnly(false);
check();
}

void check() {
    UpdateManager.create(getContext()).setChecker(new IUpdateChecker() {
        @Override
        public void check(ICheckAgent agent, String url) {
            //定制查询更新
            L.i("update " + "checking");
            HttpURLConnection connection = null;
            try {
                connection = (HttpURLConnection) new URL(url).openConnection();
                connection.setRequestProperty("Accept", "application/json");
                connection.connect();
                if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    agent.setInfo(UpdateUtil.readString(connection.getInputStream()));
                } else {
                    agent.setError(new UpdateError(UpdateError.CHECK_HTTP_STATUS, "" + connection.getResponseCode()));
                }
            } catch (IOException e) {
                e.printStackTrace();
                agent.setError(new UpdateError(UpdateError.CHECK_NETWORK_IO));
            } finally {
                if (connection != null) {
                    connection.disconnect();
                }
            }
        }
    }).setUrl(mCheckUrl).setManual(true).setNotifyId(998).setParser(new IUpdateParser() {
        @Override
        public UpdateInfo parse(String source) throws Exception {
            //定制解析过程
            UpdateInfo info = UpdateInfo.parse(source);
            L.i("url=" + info.url);
            return info;
        }
    }).setOnNotificationDownloadListener(new NotificationDownloadListener(getContext(), 998))
            .check();
}`
commented

能否提供你的文件下载地址和文件md5?