当我在模拟器中运行Hello World应用程序时,我面临致命异常,请你知道原因..
package hsz.developer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class Main extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.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);
}
}
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hsz.developer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Main"
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的:
07-18 23:16:39.578: E/Trace(754): error opening trace file: No such file or directory (2)
07-18 23:16:40.589: E/AndroidRuntime(754): FATAL EXCEPTION: main
07-18 23:16:40.589: E/AndroidRuntime(754): java.lang.NoSuchFieldError: android.support.v7.appcompat.R$styleable.AppCompatTheme
07-18 23:16:40.589: E/AndroidRuntime(754): at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:336)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:273)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
07-18 23:16:40.589: E/AndroidRuntime(754): at hsz.developer.Main.onCreate(Main.java:13)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.app.Activity.performCreate(Activity.java:5008)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.os.Looper.loop(Looper.java:137)
07-18 23:16:40.589: E/AndroidRuntime(754): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-18 23:16:40.589: E/AndroidRuntime(754): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 23:16:40.589: E/AndroidRuntime(754): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 23:16:40.589: E/AndroidRuntime(754): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-18 23:16:40.589: E/AndroidRuntime(754): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-18 23:16:40.589:E / AndroidRuntime(754):at dalvik.system.NativeStart.main(Native Method)