xuexiangjys / XUpdate

🚀A lightweight, high availability Android version update framework.(一个轻量级、高可用性的Android版本更新框架)
https://github.com/xuexiangjys/XUpdate/wiki
Apache License 2.0
2.33k stars 406 forks source link

Progress值为负数,怎么整 #13

Closed hellomrfool closed 5 years ago

hellomrfool commented 5 years ago

打印出来Progress为负数,total为-1,导致进度条不会动,找不到解决方法,HELP

xuexiangjys commented 5 years ago

你下载apk的响应报文有问题。下面是okhttp响应ResponseBody对长度的定义:

/**
   * Returns the number of bytes in that will returned by {@link #bytes}, or {@link #byteStream}, or
   * -1 if unknown.
   */
  public abstract long contentLength();

你返回-1就是未知文件大小,当然没有进度条了

hellomrfool commented 5 years ago

好的THX~