2011-07-13 95 views
0

我卡在一些不尋常的問題之間。我的應用程序運行正常,但我做了一些更改並切換工作區。現在,如果我運行我的項目,應用程序將以「Force to close」對話框關閉。

無法理解我的日誌貓錯誤的細節。

編輯:

R檔:

public static final int main=0x7f030004; 

Java代碼:

public class AlphaKidsActivity extends Activity implements OnClickListener{ 

MediaPlayer mp1; 
MediaPlayer mp2; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    mp1 = MediaPlayer.create(this, R.raw.a); 
    mp2 = MediaPlayer.create(this, R.raw.sound3); 

    final Button button1 = (Button) findViewById(R.id.birds); 
    button1.setOnClickListener(this); 

    final Button button2 = (Button) findViewById(R.id.button2); 
    button2.setOnClickListener(this); 

} 

@Override 
public void onClick(View v) { 
    switch(v.getId()) { 
    case R.id.birds: 
     mp1.start(); 
     startActivity (new Intent(getApplicationContext(), FruitsActivity.class)); 
     break; 
    case R.id.button2: 
     mp2.start(); 
     startActivity (new Intent(getApplicationContext(), BirdsActivity.class)); 
     break; 
    } 
} 

@Override 
protected void onDestroy() { 
    mp1.release(); 
    mp2.release(); 
    super.onDestroy(); 
} 

}

登錄貓細節:

07-13 09:29:43.263: INFO/ActivityManager(59): Start proc com.android.mds.kidsapps.alphakids for activity com.android.mds.kidsapps.alphakids/.AlphaKidsActivity: pid=234 uid=10031 gids={} 
07-13 09:29:43.691: DEBUG/ddm-heap(234): Got feature list request 
07-13 09:29:44.162: WARN/ResourceType(234): getEntry failing because entryIndex 4 is beyond type entryCount 1 
07-13 09:29:44.162: WARN/ResourceType(234): Failure getting entry for 0x7f030004 (t=2 e=4) in package 0: 0x80000001 


07-13 09:29:44.212: ERROR/AndroidRuntime(234): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.mds.kidsapps.alphakids/com.android.mds.kidsapps.alphakids.AlphaKidsActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.ActivityThread.access$2200(ActivityThread.java:119) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.os.Handler.dispatchMessage(Handler.java:99) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.os.Looper.loop(Looper.java:123) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.ActivityThread.main(ActivityThread.java:4363) 
    07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at java.lang.reflect.Method.invokeNative(Native Method) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at java.lang.reflect.Method.invoke(Method.java:521) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at dalvik.system.NativeStart.main(Native Method) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030004 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.content.res.Resources.getValue(Resources.java:891) 
    07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:1865) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.content.res.Resources.getLayout(Resources.java:730) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.view.LayoutInflater.inflate(LayoutInflater.java:318) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.Activity.setContentView(Activity.java:1622) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at com.android.mds.kidsapps.alphakids.AlphaKidsActivity.onCreate(AlphaKidsActivity.java:19) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
07-13 09:29:44.212: ERROR/AndroidRuntime(234):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 
+1

清潔項目,重建。檢查你的R.java中的ID是什麼以及它爲什麼丟失。 – dmon

+0

發佈您的onCreate方法的代碼 – Rasel

+0

@dmon請參閱更新的問題 – vnshetty

回答

1

檢查是否產生R.java文件,或無法按照根指令或某些時候出現問題「進口android.R」項目。如果你發現「import android.R;」在你的班級中刪除它。

+0

同樣,R.java文件可能被意外地包含在反編譯內容中。這發生在我身上(是的,反編譯是道德的),並且一旦我刪除了額外的R.java文件就解決了。 – Venryx

0

這可能會導致由於缺少可繪製的圖像

相關問題