Comments (3)
这是你自己代码写的有问题,知道嘛。
handler创建请指明Looper, 不要在子线程里面创建handler
from xupdate.
新建的项目,没有包含其他代码,只添加了XUpdate
报如下错误。不知道哪里写的有问题。
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
MainActivity只有以下代码:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
XUpdate.newBuild(this)
.updateUrl("http://192.168.1.151/update.json")
.updatePrompter(new CustomUpdatePrompter())
.update();
}
}
在BaseApplication中初始化代码:
private void initUpdae(){
XUpdate.get()
.debug(true)
//设置默认只有在Wifi下检测版本
.isWifiOnly(false)
//默认使用get检查版本
.isGet(true)
//默认设置非自动模式,可以根据情况使用配置
.isAutoMode(false)
//设置默认公共请求参数
.param("versionCode" , UpdateUtils.getVersionCode(this))
.param("appKey" , getPackageName())
//设置版本更新出错监听
.setOnUpdateFailureListener(new OnUpdateFailureListener() {
@OverRide
public void onFailure(UpdateError error) {
System.out.println(error.toString());
error.printStackTrace();
if (error.getCode() != CHECK_NO_NEW_VERSION){
System.out.println(error.toString());
}
}
})
//设置是否支持静默安装,默认是true
.supportSilentInstall(false)
.setIUpdateHttpService(new OKHttpUpdateHttpService())
.init(this);
}
使用demo中自带的两个类文件
打开APP出现如下错误。
from xupdate.
这是你自己代码写的有问题,知道嘛。 handler创建请指明Looper, 不要在子线程里面创建handler
.updatePrompter(new CustomUpdatePrompter())
注释上面的代码就没有问题。
from xupdate.
Related Issues (20)
- 如果只需要下载APK功能和后台下载功能
- 发生android.util.SuperNotCalledException异常 HOT 1
- 使用这个库没办法后台显示Notification的下载进度 HOT 2
- java.lang.RuntimeException: Unable to get provider com.xuexiang.xupdate.utils.UpdateFileProvider HOT 2
- 下载出现异常如果是强制更新能否不关闭弹窗,可以点击重新下载 HOT 1
- 请问请求头如何设置? HOT 1
- 鸿蒙系统更新问题,提示不能安装 HOT 1
- 当请求接口处于超时状态下,多次点击下载会出现ANR 问题 HOT 1
- Android12无法更新&下载安装包(单独)&安装软件 HOT 1
- 可以在App更新完成后再自动启动App吗? HOT 1
- 2.1.3版本被google play拒了 HOT 5
- 啥时候能支持rxjava3 HOT 1
- 可以直接从构建UpdateEntity版本更新实体开始使用框架吗? HOT 1
- 安卓4.4.2无法使用,报错:java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. HOT 1
- 能否支持在更新信息上,添加网页超链接,用户点击链接后,可通过浏览器打开链接。 HOT 1
- 安装后自动删除apk包 HOT 1
- targetSdk > 30时且使用后台更新模式,显示apk下载完成通知时会抛出异常
- 第一次授权后,返回应用,不会自动安装 HOT 1
- 请问如何添加请求头 HOT 1
- 实现app更新的api是需要自己写么 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xupdate.