使用操作栏sherlock库启动时具有空指针异常(并非总是)

时间:2013-10-13 00:50:56

标签: android nullpointerexception actionbarsherlock

所以我在我的应用程序中使用动作栏sherlock库作为操作栏。即使我不确定问题是否因此发生,但我觉得它是由于abs?但奇怪的是,当我重新启动手机和ADT并删除应用程序然后清理项目并运行它再次工作的项目。但是当它工作正常,然后它可能会突然停止工作。我需要解决这个问题。谢谢百万!

  

10-12 23:40:51.905:I / dalvikvm(1528):找不到方法   com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout.onHoverEvent,   从方法中引用   com.actionbarsherlock.internal.widget.ActionBarContainer.onHoverEvent   10-12 23:40:51.905:W / dalvikvm(1528):VFY:无法解析虚拟   方法4266:   LCOM / actionbarsherlock /内部/ nineoldandroids /插件/ NineFrameLayout; .onHoverEvent   (Landroid / view / MotionEvent;)Z 10-12 23:40:51.905:D / dalvikvm(1528):   VFY:将操作码0x6f替换为0x0000 10-12 23:40:51.905:   D / dalvikvm(1528):VFY:死代码0x0003-0004 in   LCOM / actionbarsherlock /内部/插件/ ActionBarContainer; .onHoverEvent   (Landroid / view / MotionEvent;)Z 10-12 23:40:51.915:I / dalvikvm(1528):   找不到方法android.widget.FrameLayout.getAlpha,引用   从方法   com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout.getAlpha   10-12 23:40:51.915:W / dalvikvm(1528):VFY:无法解析虚拟   方法3019:Landroid / widget / FrameLayout; .getAlpha()F 10-12   23:40:51.915:D / dalvikvm(1528):VFY:在0x000b处替换操作码0x6f   10-12 23:40:51.915:D / dalvikvm(1528):VFY:死代码0x000e-000f in   LCOM / actionbarsherlock /内部/ nineoldandroids /插件/ NineFrameLayout; .getAlpha   ()F 10-12 23:40:51.915:I / dalvikvm(1528):找不到方法   android.widget.FrameLayout.getTranslationY,从方法引用   com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout.getTranslationY   10-12 23:40:51.915:W / dalvikvm(1528):VFY:无法解析虚拟   方法3020:Landroid / widget / FrameLayout; .getTranslationY()F 10-12   23:40:51.915:D / dalvikvm(1528):VFY:在0x000b处替换操作码0x6f   10-12 23:40:51.915:D / dalvikvm(1528):VFY:死代码0x000e-000f in   LCOM / actionbarsherlock /内部/ nineoldandroids /插件/ NineFrameLayout; .getTranslationY   ()F 10-12 23:40:51.915:I / dalvikvm(1528):找不到方法   android.widget.FrameLayout.setAlpha,从方法引用   com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout.setAlpha   10-12 23:40:51.915:W / dalvikvm(1528):VFY:无法解析虚拟   方法3023:Landroid / widget / FrameLayout; .setAlpha(F)V 10-12   23:40:51.915:D / dalvikvm(1528):VFY:在0x000a处替换操作码0x6f   10-12 23:40:51.915:D / dalvikvm(1528):VFY:死代码0x000d-000d in   LCOM / actionbarsherlock /内部/ nineoldandroids /插件/ NineFrameLayout; .setAlpha   (F)V 10-12 23:40:51.915:I / dalvikvm(1528):找不到方法   android.widget.FrameLayout.setTranslationY,从方法引用   com.actionbarsherlock.internal.nineoldandroids.widget.NineFrameLayout.setTranslationY   10-12 23:40:51.915:W / dalvikvm(1528):VFY:无法解析虚拟   方法3030:Landroid / widget / FrameLayout; .setTranslationY(F)V 10-12   23:40:51.915:D / dalvikvm(1528):VFY:在0x000a处替换操作码0x6f   10-12 23:40:51.915:D / dalvikvm(1528):VFY:死代码0x000d-000d in   LCOM / actionbarsherlock /内部/ nineoldandroids /插件/ NineFrameLayout; .setTranslationY   (F)V 10-12 23:40:51.925:I / dalvikvm(1528):找不到方法   android.content.pm.PackageManager.getActivityLogo,引用自   方法com.actionbarsherlock.internal.widget.ActionBarView。 10-12   23:40:51.925:W / dalvikvm(1528):VFY:无法解析虚方法   300:Landroid / content / pm / PackageManager; .getActivityLogo   (Landroid /内容/组件名)Landroid /图形/抽拉/绘制对象;   10-12 23:40:51.925:D / dalvikvm(1528):VFY:替换操作码0x6e at   0x01d1 10-12 23:40:51.925:I / dalvikvm(1528):找不到方法   android.content.pm.ApplicationInfo.loadLogo,从方法引用   com.actionbarsherlock.internal.widget.ActionBarView。 10-12   23:40:51.925:W / dalvikvm(1528):VFY:无法解析虚方法   296:Landroid / content / pm / ApplicationInfo; .loadLogo   (Landroid /内容/ PM / PackageManager)Landroid /图形/抽拉/绘制对象;   10-12 23:40:51.925:D / dalvikvm(1528):VFY:替换操作码0x6e at   0x01df 10-12 23:40:51.925:D / dalvikvm(1528):VFY:死代码   Lcom / actionbarsherlock / internal / widget / ActionBarView;中的0x01d4-01d8。   (Landroid / content / Context; Landroid / util / AttributeSet;)V 10-12   23:40:51.925:D / dalvikvm(1528):VFY:死代码0x01e2-01e8 in   LCOM / actionbarsherlock /内部/插件/ ActionBarView ;.   (Landroid / content / Context; Landroid / util / AttributeSet;)V 10-12   23:40:51.955:I / dalvikvm(1528):找不到方法   android.view.ViewGroup.getAlpha,从方法引用   com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup.getAlpha   10-12 23:40:51.955:W / dalvikvm(1528):VFY:无法解析虚拟   方法2789:Landroid / view / ViewGroup; .getAlpha()F 10-12 23:40:51.955:   D / dalvikvm(1528):VFY:将操作码0x6f替换为0x000b 10-12   23:40:51.955:D / dalvikvm(1528):VFY:死代码0x000e-000f in   LCOM / actionbarsherlock /内部/ nineoldandroids /视图/ NineViewGroup; .getAlpha   ()F 10-12 23:40:51.955:I / dalvikvm(1528):找不到方法   android.view.ViewGroup.getTranslationX,从方法引用   com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup.getTranslationX   10-12 23:40:51.955:W / dalvikvm(1528):VFY:无法解析虚拟   方法2794:Landroid / view / ViewGroup; .getTranslationX()F 10-12   23:40:51.955:D / dalvikvm(1528):VFY:在0x000b处替换操作码0x6f   10-12 23:40:51.955:D / dalvikvm(1528):VFY:死代码0x000e-000f in   LCOM / actionbarsherlock /内部/ nineoldandroids /视图/ NineViewGroup; .getTranslationX   ()F 10-12 23:40:51.955:I / dalvikvm(1528):找不到方法   android.view.ViewGroup.getTranslationY,从方法引用   com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup.getTranslationY   10-12 23:40:51.955:W / dalvikvm(1528):VFY:无法解析虚拟   方法2795:Landroid / view / ViewGroup; .getTranslationY()F 10-12   23:40:51.955:D / dalvikvm(1528):VFY:在0x000b处替换操作码0x6f   10-12 23:40:51.955:D / dalvikvm(1528):VFY:死代码0x000e-000f in   LCOM / actionbarsherlock /内部/ nineoldandroids /视图/ NineViewGroup; .getTranslationY   ()F 10-12 23:40:51.955:I / dalvikvm(1528):找不到方法   android.view.ViewGroup.setAlpha,从方法引用   com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup.setAlpha   10-12 23:40:51.955:W / dalvikvm(1528):VFY:无法解析虚拟   方法2810:Landroid / view / ViewGroup; .setAlpha(F)V 10-12   23:40:51.955:D / dalvikvm(1528):VFY:在0x000a处替换操作码0x6f   10-12 23:40:51.955:D / dalvikvm(1528):VFY:死代码0x000d-000d in   LCOM / actionbarsherlock /内部/ nineoldandroids /视图/ NineViewGroup; .setAlpha   (F)V 10-12 23:40:51.955:I / dalvikvm(1528):找不到方法   android.view.ViewGroup.setTranslationX,从方法引用   com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup.setTranslationX   10-12 23:40:51.955:W / dalvikvm(1528):VFY:无法解析虚拟   方法2814:Landroid / view / ViewGroup; .setTranslationX(F)V 10-12   23:40:51.955:D / dalvikvm(1528):VFY:在0x000a处替换操作码0x6f   10-12 23:40:51.955:D / dalvikvm(1528):VFY:死代码0x000d-000d in   LCOM / actionbarsherlock /内部/ nineoldandroids /视图/ NineViewGroup; .setTranslationX   (F)V 10-12 23:40:51.955:I / dalvikvm(1528):找不到方法   android.view.ViewGroup.setTranslationY,从方法引用   com.actionbarsherlock.internal.nineoldandroids.view.NineViewGroup.setTranslationY   10-12 23:40:51.955:W / dalvikvm(1528):VFY:无法解析虚拟   方法2815:Landroid / view / ViewGroup; .setTranslationY(F)V 10-12   23:40:51.955:D / dalvikvm(1528):VFY:在0x000a处替换操作码0x6f   10-12 23:40:51.955:D / dalvikvm(1528):VFY:死代码0x000d-000d in   LCOM / actionbarsherlock /内部/ nineoldandroids /视图/ NineViewGroup; .setTranslationY   (F)V 10-12 23:40:51.985:D / dalvikvm(1528):GC_EXTERNAL_ALLOC被释放   1437个对象/ 98064字节,28ms 10-12 23:40:52.285:   I / dalvikvm(1528):找不到方法   com.actionbarsherlock.internal.widget.ActionBarView $ HomeView.onHoverEvent,   从方法中引用   com.actionbarsherlock.internal.widget.ActionBarView $ HomeView.dispatchHoverEvent   10-12 23:40:52.285:W / dalvikvm(1528):VFY:无法解析虚拟   方法5127:   LCOM / actionbarsherlock /内部/空间/ ActionBarView $ HomeView; .onHoverEvent   (Landroid / view / MotionEvent;)Z 10-12 23:40:52.285:D / dalvikvm(1528):   VFY:将代码0x6e替换为0x0000 10-12 23:40:52.285:   D / dalvikvm(1528):VFY:死代码0x0003-0004 in   LCOM / actionbarsherlock /内部/空间/ ActionBarView $ HomeView; .dispatchHoverEvent   (Landroid / view / MotionEvent;)Z 10-12 23:40:52.285:I / dalvikvm(1528):   找不到方法   android.widget.FrameLayout.onPopulateAccessibilityEvent,引用   从方法   com.actionbarsherlock.internal.widget.ActionBarView $ HomeView.onPopulateAccessibilityEvent   10-12 23:40:52.285:W / dalvikvm(1528):VFY:无法解析虚拟   方法3022:Landroid / widget / FrameLayout; .onPopulateAccessibilityEvent   (Landroid / view / accessibility / AccessibilityEvent;)V 10-12 23:40:52.285:   D / dalvikvm(1528):VFY:将操作码0x6f替换为0x0006 10-12   23:40:52.345:D / AndroidRuntime(1528):关闭VM 10-12   23:40:52.345:W / dalvikvm(1528):threadid = 1:线程退出   未捕获的异常(组= 0x400259f8)10-12 23:40:52.355:   E / AndroidRuntime(1528):致命异常:主10-12 23:40:52.355:   E / AndroidRuntime(1528):java.lang.RuntimeException:无法启动   活动   ComponentInfo {com.id11313982.freejokesapp / com.id11313982.freejokesapp.activities.MainActivity}:java.lang.NullPointerException 10-12 23:40:52.355:   E / AndroidRuntime(1528):at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2787)   10-12 23:40:52.355:E / AndroidRuntime(1528):at   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)   10-12 23:40:52.355:E / AndroidRuntime(1528):at   android.app.ActivityThread.access $ 2300(ActivityThread.java:135)10-12   23:40:52.355:E / AndroidRuntime(1528):at   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:2136)   10-12 23:40:52.355:E / AndroidRuntime(1528):at   android.os.Handler.dispatchMessage(Handler.java:99)10-12   23:40:52.355:E / AndroidRuntime(1528):at   android.os.Looper.loop(Looper.java:145)10-12 23:40:52.355:   E / AndroidRuntime(1528):at   android.app.ActivityThread.main(ActivityThread.java:4937)10-12   23:40:52.355:E / AndroidRuntime(1528):at   java.lang.reflect.Method.invokeNative(Native Method)10-12   23:40:52.355:E / AndroidRuntime(1528):at   java.lang.reflect.Method.invoke(Method.java:521)10-12 23:40:52.355:   E / AndroidRuntime(1528):at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868)   10-12 23:40:52.355:E / AndroidRuntime(1528):at   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)10-12   23:40:52.355:E / AndroidRuntime(1528):at   dalvik.system.NativeStart.main(Native Method)10-12 23:40:52.355:   E / AndroidRuntime(1528):引起:java.lang.NullPointerException   10-12 23:40:52.355:E / AndroidRuntime(1528):at   com.id11313982.freejokesapp.activities.MainActivity.networkStatusMessage(MainActivity.java:202)   10-12 23:40:52.355:E / AndroidRuntime(1528):at   com.id11313982.freejokesapp.activities.MainActivity.onCreate(MainActivity.java:78)10-12 23:40:52.355:E / AndroidRuntime(1528):at   android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)   10-12 23:40:52.355:E / AndroidRuntime(1528):at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)   10-12 23:40:52.355:E / AndroidRuntime(1528):... 11 more

public void networkStatusMessage()  
{
    mJokeView = (TextView) findViewById(R.id.joke_portion_textview_main_activity);
        HelperClass.ShowErrorMessage(getBaseContext(), getString(R.string.connection_not_available_status_localjokeread));
        mJokeView.setText(getString(R.string.connection_not_available_status_localjokeread));
        mJokeView.setGravity(Gravity.CENTER);
    mJokeTitleView.setText("");
            }

protected void onCreate(Bundle savedInstanceState)  {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        actionBar=getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);

        helperClass = new HelperClass();
    stillRandomJoke = true;
        if(helperClass.isNetworkAvailable(MainActivity.this))
    {
        dataBundle = new Bundle();
        dataBundle = helperClass.restoreCategoryPreference(MainActivity.this);
            if(dataBundle.getString(CATEGORY_NAME) != null && dataBundle.getInt(CATEGORY_ID) != 0)
        {
            startJokeId = dataBundle.getInt(FROM_ID);
                endJokeId = dataBundle.getInt(TO_ID);
                currentJokeId = helperClass.restoreJokeIDPreference(MainActivity.this);

                stillRandomJoke = false;
                IssueHTTPRequestForEachJoke(SELECTED_JOKE_URL + currentJokeId);
        }
        else
                IssueHTTPRequestForEachJoke(RANDOM_JOKE_URL);
    }
    else
        networkStatusMessage();
}

1 个答案:

答案 0 :(得分:0)

我的猜测是networkStatusMessage的第202行是这一行:

mJokeTitleView.setText("");

mJokeTitleViewnull,因为您从未设置它。