你有实现这个方法吗?
getPlayModeSingle提示null指针一般是运行时的, 编译时提示? 一般不大可能

解决方案 »

  1.   

    运行时提示 ,就是run的时候中断了,log里提示空指针,
    在CommonApplication中,实现了getPlayModeSingle方法。
      

  2.   

    可能用的还是系统的APP吧ActivityThread中 attach Application的代码在: try {
                Application app = r.packageInfo.makeApplication(false);
                
                if (localLOGV) Log.v(TAG, "Performing launch of " + r);
                if (localLOGV) Log.v(
                        TAG, r + ": app=" + app
                        + ", appName=" + app.getPackageName()
                        + ", pkg=" + r.packageInfo.getPackageName()
                        + ", comp=" + r.intent.getComponent().toShortString()
                        + ", dir=" + r.packageInfo.getAppDir());            if (activity != null) {
                    ApplicationContext appContext = new ApplicationContext();
                    appContext.init(r.packageInfo, r.token, this);
                    appContext.setOuterContext(activity);
                    CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager());
                    Configuration config = new Configuration(mConfiguration);
                    activity.attach(appContext, this, getInstrumentation(), r.token,
                            r.ident, app, r.intent, r.activityInfo, title, r.parent,
                            r.embeddedID, r.lastNonConfigurationInstance,
                            r.lastNonConfigurationChildInstances, config);
                    
                    if (customIntent != null) {
                        activity.mIntent = customIntent;
                    }
                    r.lastNonConfigurationInstance = null;
                    r.lastNonConfigurationChildInstances = null;
                    activity.mStartedActivity = false;
                    int theme = r.activityInfo.getThemeResource();
                    if (theme != 0) {
                        activity.setTheme(theme);
                    }                activity.mCalled = false;
                    mInstrumentation.callActivityOnCreate(activity, r.state);
                    if (!activity.mCalled) {
                        throw new SuperNotCalledException(
                            "Activity " + r.intent.getComponent().toShortString() +
                            " did not call through to super.onCreate()");
                    }
                    r.activity = activity;
                    r.stopped = true;
                    if (!r.activity.mFinished) {
                        activity.performStart();
                        r.stopped = false;
                    }
                    if (!r.activity.mFinished) {
                        if (r.state != null) {
                            mInstrumentation.callActivityOnRestoreInstanceState(activity, r.state);
                        }
                    }
                    if (!r.activity.mFinished) {
                        activity.mCalled = false;
                        mInstrumentation.callActivityOnPostCreate(activity, r.state);
                        if (!activity.mCalled) {
                            throw new SuperNotCalledException(
                                "Activity " + r.intent.getComponent().toShortString() +
                                " did not call through to super.onPostCreate()");
                        }
                    }
                    r.state = null;
                }
                r.paused = true;            mActivities.put(r.token, r);        } catch (SuperNotCalledException e) {
                throw e;        } catch (Exception e) {
                if (!mInstrumentation.onException(activity, e)) {
                    throw new RuntimeException(
                        "Unable to start activity " + component
                        + ": " + e.toString(), e);
                }
            }
    其中makeApplication的代码,可能要调一下:
    public Application makeApplication(boolean forceDefaultAppClass) {
                if (mApplication != null) {
                    return mApplication;
                }
                
                Application app = null;
                
                String appClass = mApplicationInfo.className;
                if (forceDefaultAppClass || (appClass == null)) {
                    appClass = "android.app.Application";
                }            try {
                    java.lang.ClassLoader cl = getClassLoader();
                    ApplicationContext appContext = new ApplicationContext();
                    appContext.init(this, null, mActivityThread);
                    app = mActivityThread.mInstrumentation.newApplication(
                            cl, appClass, appContext);
                    appContext.setOuterContext(app);
                } catch (Exception e) {
                    if (!mActivityThread.mInstrumentation.onException(app, e)) {
                        throw new RuntimeException(
                            "Unable to instantiate application " + appClass
                            + ": " + e.toString(), e);
                    }
                }
                mActivityThread.mAllApplications.add(app);
                return mApplication = app;
            }
      

  3.   

    android:name=".CommonApplication"改成完整的名字试试?android:name="com.xxx.xxx.CommonApplication"从源代码看,估计这个name直接赋值给mApplicationInfo.className的