Balakrishnan
Balakrishnan

Reputation: 266

Unfortunately My app has stopped [Android Emulator]

While I am adding an Action bar, emulator will be displayed "Unfortunately MainActivity has stopped", even no error and installed

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.trintwo"     
      android:versionCode="1"
      android:versionName="1.0">
<uses-sdk
        android:minSdkVersion = "7"
        android:targetSdkVersion = "18" />

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
        <activity android:name="MainActivity"
                  android:label="@string/app_name"
                  android:theme="@style/Theme.Holo.Light">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
                android:name = "com.example.trintwo.DisplayMessageActivity"
                android:label = "@string/title_activity_display_message"
                android:parentActivityName = "com.example.trintwo.MainActivity">
                <meta-data
                        android:name = "android.support.PARENT_ACTIVITY"
                        android:value = "com.example.trintwo.MainActivity" />
        </activity>
    </application>
</manifest>

This is my res/values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<!--
    Base application theme for API 14+. This theme completely replaces
    AppBaseTheme from BOTH res/values/styles.xml and
    res/values-v11/styles.xml on API 14+ devices.
-->
        <style name="AppBaseTheme" parent="android:Theme.Holo.Light"></style>
        <style name="CustomActionBarTheme"
                 parent="@android:style/Theme.Holo.Light.DarkActionBar">

        </style>

</resources>

debug successfully and installed successfully but emulator show this "Unfortunately MainActivity has stopped"

I am using terminal [not eclipse]

Upvotes: 0

Views: 13365

Answers (6)

satishgoda
satishgoda

Reputation: 398

I ran into the same problem while going through a tutorial.

What seemed to worked for me is cleaning my project in Eclipse and running my app on my device again.

Upvotes: 1

Harshit Jain
Harshit Jain

Reputation: 331

Are you building the app for the correct API Level?

If your API level is below 11 you need to import android.support.v7.app.ActionBar

Otherwise import android.app.ActionBar

Upvotes: 0

Wesam Torman
Wesam Torman

Reputation: 288

there is no

<uses-sdk> 

tag at your manifest please show this link and this to add your SDKs Link2

Upvotes: 0

Ilya Gazman
Ilya Gazman

Reputation: 32221

Welcome to Stackoverflow!

Unfortunately MainActivity has stopped

There is only one reason for that. You got an EXCEPTION. You need to install logcat some how. It will tell you what it is.

Show us the log exception and we will help you.

Upvotes: 1

robnick
robnick

Reputation: 1768

Assuming you added the CustomActionBarTheme style to your styles.xml file (per your code sample) then there's nothing wrong with that markup.

Can you provide the markup that is using the CustomActionBarTheme style?

Also, if you remove that style altogether does the app run? Always a good idea to reverse changes until you get back to a working version then line-by-line add the potentially offending code back in.

Upvotes: 1

Nathan Walters
Nathan Walters

Reputation: 4126

You seem to be missing the attribute from your manifest. This could be your problem. For more information, see here: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

Upvotes: 2

Related Questions