创建了一个简单的hello world应用程序,当我第一次通过eclips将其上传到AVD时可以正常工作。但当我关闭它并尝试在AVD中再次打开它时,它会启动,然后弹出“不幸(appname)已停止”消息。
MainActivity.java:
package com.example.robin;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@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);
}
}
我的Android manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.robin"
android:versionCode="1"
android:versionName="1.0" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
LogCat:
09-28 10:24:41.903: W/dalvikvm(2794): VFY: unable to resolve static field 1864 (ActionBarWindow) in Landroid/support/v7/appcompat/R$styleable;
09-28 10:24:41.903: D/dalvikvm(2794): VFY: replacing opcode 0x62 at 0x0004
09-28 10:24:41.973: D/AndroidRuntime(2794): Shutting down VM
09-28 10:24:41.983: W/dalvikvm(2794): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
09-28 10:24:42.003: E/AndroidRuntime(2794): FATAL EXCEPTION: main
09-28 10:24:42.003: E/AndroidRuntime(2794): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:106)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
09-28 10:24:42.003: E/AndroidRuntime(2794): at com.example.hello.ROBIN_APP.onCreate(ROBIN_APP.java:13)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.app.Activity.performCreate(Activity.java:5104)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.os.Handler.dispatchMessage(Handler.java:99)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.os.Looper.loop(Looper.java:137)
09-28 10:24:42.003: E/AndroidRuntime(2794): at android.app.ActivityThread.main(ActivityThread.java:5041)
09-28 10:24:42.003: E/AndroidRuntime(2794): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 10:24:42.003: E/AndroidRuntime(2794): at java.lang.reflect.Method.invoke(Method.java:511)
09-28 10:24:42.003: E/AndroidRuntime(2794): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-28 10:24:42.003: E/AndroidRuntime(2794): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-28 10:24:42.003: E/AndroidRuntime(2794): at dalvik.system.NativeStart.main(Native Method)