2014-06-26 41 views
0

我的應用程序崩潰時甚至沒有顯示在屏幕上。任何人都可以告訴我是什麼導致了錯誤,以及如何解決它?我在網上查找,但找不到與錯誤代碼0x40b1f930有關的任何內容。threadid = 1:線程以未捕獲的異常退出(group = 0x40b1f930)

public class MainActivity extends ActionBarActivity { 
int i = 0; 
int score = 0; 
int lives = 5; 
int xValue = 0; 
int yValue = 0; 
Thread gameThread; 
Boolean gameover = true; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    if (savedInstanceState == null) { 
     getSupportFragmentManager().beginTransaction() 
       .add(R.id.container, new PlaceholderFragment()).commit(); 
    } 
    gameThread = new Thread() { 
     public void run() { 
      try { 
       sleep(1000); 
       if (!gameover) { 
        while(!gameover) { 
         if (i == 0) { 
          //add image 
         } 

         if (score < 10) { 
          if (i > 40) { 
           //remove image 
           lives--; 
           i = 0; 
          } 
         } 
         else if (score >= 10 && score < 25) { 
          if (i > 30) { 
           //remove image 
           lives--; 
           i = 0; 
          } 
         } 
         else if (score >= 25 && score < 40) { 
          if (i > 20) { 
           //remove image 
           lives--; 
           i = 0; 
          } 
         } 
         else { 
          if (i > 10) { 
           //remove image 
           lives--; 
           i = 0; 
          } 
         } 
        }//end of while 
       } 
      } //end of try 
      catch (InterruptedException e) { 
       e.printStackTrace(); 
      } 
     } 
    }; //end of gameThread 
} //end of on create 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 

    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.main, menu); 
    return true; 
} 

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle action bar item clicks here. The action bar will 
    // automatically handle clicks on the Home/Up button, so long 
    // as you specify a parent activity in AndroidManifest.xml. 
    int id = item.getItemId(); 
    if (id == R.id.action_settings) { 
     return true; 
    } 
    return super.onOptionsItemSelected(item); 
} 

/** 
* A placeholder fragment containing a simple view. 
*/ 
public static class PlaceholderFragment extends Fragment { 

    public PlaceholderFragment() { 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     View rootView = inflater.inflate(R.layout.fragment_main, container, 
       false); 
     return rootView; 
    } 
} 
public void gameStartMethod() { 
    gameover = false; 
    //remove startButton 
    gameThread.start(); 
    score = 0; 
    lives = 5; 
    i = 0; 
} 
} 

日誌文件看起來像這樣:

06-27 08:59:43.780: I/Process(30512): Sending signal. PID: 30512 SIG: 9 

06-27 08:59:46.140: W/dalvikvm(30719): VFY: unable to resolve static field 1559 (ActionBarWindow) in Landroid/support/v7/appcompat/R$styleable; 

06-27 08:59:46.140: D/dalvikvm(30719): VFY: replacing opcode 0x62 at 0x0004 

06-27 08:59:46.140: D/AndroidRuntime(30719): Shutting down VM 

06-27 08:59:46.140: W/dalvikvm(30719): threadid=1: thread exiting with uncaught exception 
(group=0x40b1f930) 

06-27 08:59:46.140: E/AndroidRuntime(30719): FATAL EXCEPTION: main 

06-27 08:59:46.140: E/AndroidRuntime(30719): java.lang.NoClassDefFoundError: 
android.support.v7.appcompat.R$styleable 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at pineappletech.com.reactiontest.MainActivity.onCreate(MainActivity.java:23) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.app.Activity.performCreate(Activity.java:5104) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.app.ActivityThread.access$600(ActivityThread.java:141) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.os.Handler.dispatchMessage(Handler.java:99) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.os.Looper.loop(Looper.java:137) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at android.app.ActivityThread.main(ActivityThread.java:5041) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at java.lang.reflect.Method.invokeNative(Native Method) 
06-27 08:59:46.140: E/AndroidRuntime(30719): at java.lang.reflect.Method.invoke(Method.java:511) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 

06-27 08:59:46.140: E/AndroidRuntime(30719): at dalvik.system.NativeStart.main(Native Method) 
+0

看看這個答案:http://stackoverflow.com/a/20900934/1007510 – Chris

+0

感謝它的工作 – Zephranoid

回答

0

它看起來像圖書館android.support.v7.appcompat.R $設置樣式不被發現..你包括在你的構建設置?

+0

oops只是注意到@Chris的評論點擊鏈接..它可能是你的問題。 – erik

相關問題