首页 > 代码库 > Android - 错误:Unable to instantiate application

Android - 错误:Unable to instantiate application

错误:Unable to instantiate application


本文地址: http://blog.csdn.net/caroline_wendy


错误:java.lang.RuntimeException: Unable to instantiate application me.chunyu.paddoctor.Activity
Java运行时异常,不能实例化应用:XXX.

原因:
<application>的”android:name”属性错误,即android:name=“me.cxxxyx.paddoctor.Activity”有问题;
可以新建一个App类继承父类的App,再指定android:name,即android:name=“me.cxxxyx.paddoctor.HelloApp”;

/**
 * Created by wangchenlong on 14-11-18.
 */

public class HelloApp extends CxxxyxApp {
    @Override
    public boolean isTelecomVip() {
        return false;
    }

    @Override
    public boolean showUnicomVip() {
        return false;
    }

    @Override
    public int appId() {
        return 0;
    }

    @Override
    public boolean isMainActivity(Activity activity) {
        return false;
    }
}


默认生成的Android项目,不需要AndroidManifest的<application>标签中设置name属性;
但是定制的项目就必须指定<application>的name属性才可以使用。








Android - 错误:Unable to instantiate application