I just new in android development. In fact I started it just earlier this afternoon. I follow the instruction in this link.
https://developer.android.com/training/basics/firstapp/creating-project.html
I just rename it as hello2.
Everything seems perfect except when I was trying to run it in AVD. My logcat keeps popping some errors. And the emulator display "Unfortunately, hello2 has stopped."
can somebody out there help me?
this is my java file
package com.example.hello2;
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);
}
}
this is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hello2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<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>
and this is my logcat:
07-20 13:22:25.760: W/dalvikvm(960): threadid=1: thread exiting with uncaught exception (group=0xb3af1d70)
07-20 13:22:25.780: E/AndroidRuntime(960): FATAL EXCEPTION: main
07-20 13:22:25.780: E/AndroidRuntime(960): Process: com.example.hello2, PID: 960
07-20 13:22:25.780: E/AndroidRuntime(960): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hello2/com.example.hello2.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.os.Handler.dispatchMessage(Handler.java:102)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.os.Looper.loop(Looper.java:136)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.ActivityThread.main(ActivityThread.java:5026)
07-20 13:22:25.780: E/AndroidRuntime(960): at java.lang.reflect.Method.invokeNative(Native Method)
07-20 13:22:25.780: E/AndroidRuntime(960): at java.lang.reflect.Method.invoke(Method.java:515)
07-20 13:22:25.780: E/AndroidRuntime(960): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-20 13:22:25.780: E/AndroidRuntime(960): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-20 13:22:25.780: E/AndroidRuntime(960): at dalvik.system.NativeStart.main(Native Method)
07-20 13:22:25.780: E/AndroidRuntime(960): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-20 13:22:25.780: E/AndroidRuntime(960): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-20 13:22:25.780: E/AndroidRuntime(960): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-20 13:22:25.780: E/AndroidRuntime(960): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-20 13:22:25.780: E/AndroidRuntime(960): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.Activity.setContentView(Activity.java:1930)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-20 13:22:25.780: E/AndroidRuntime(960): at com.example.hello2.MainActivity.onCreate(MainActivity.java:13)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.Activity.performCreate(Activity.java:5242)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-20 13:22:25.780: E/AndroidRuntime(960): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-20 13:22:25.780: E/AndroidRuntime(960): ... 11 more
I hope somebody can help me..
PS: sorry for the bad English.