Coder Social home page Coder Social logo

Comments (3)

xuexiangjys avatar xuexiangjys commented on July 24, 2024

这是你自己代码写的有问题,知道嘛。
handler创建请指明Looper, 不要在子线程里面创建handler

from xupdate.

aije avatar aije commented on July 24, 2024

新建的项目,没有包含其他代码,只添加了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中自带的两个类文件

image

打开APP出现如下错误。

image

from xupdate.

aije avatar aije commented on July 24, 2024

这是你自己代码写的有问题,知道嘛。 handler创建请指明Looper, 不要在子线程里面创建handler

.updatePrompter(new CustomUpdatePrompter())

注释上面的代码就没有问题。

from xupdate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.