0

I am a beginner in android application & just started building first "HelloWorld" app. i followed official tutorial and designed emulator. But when i run it, the emulator says "Unfortunately, AndroidFirst has stopped". I looked around on SO but different solutions didn't help. I am a very beginner for Android, hence can't find the bug or something like wrong/error.

following is logCat:

08-29 05:16:58.629: W/dalvikvm(1934): VFY: unable to resolve static field 1864 (ActionBarWindow) in Landroid/support/v7/appcompat/R$styleable;
08-29 05:16:58.629: D/dalvikvm(1934): VFY: replacing opcode 0x62 at 0x0004
08-29 05:16:58.649: D/AndroidRuntime(1934): Shutting down VM
08-29 05:16:58.649: W/dalvikvm(1934): threadid=1: thread exiting with uncaught exception (group=0xb1daece8)
08-29 05:16:58.669: E/AndroidRuntime(1934): FATAL EXCEPTION: main
08-29 05:16:58.669: E/AndroidRuntime(1934): Process: com.example.androidfirst, PID: 1934
08-29 05:16:58.669: E/AndroidRuntime(1934): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:106)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at com.example.androidfirst.MainActivity.onCreate(MainActivity.java:13)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.app.Activity.performCreate(Activity.java:5242)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.os.Handler.dispatchMessage(Handler.java:102)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.os.Looper.loop(Looper.java:136)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at android.app.ActivityThread.main(ActivityThread.java:5026)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at java.lang.reflect.Method.invokeNative(Native Method)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at java.lang.reflect.Method.invoke(Method.java:515)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
08-29 05:16:58.669: E/AndroidRuntime(1934):     at dalvik.system.NativeStart.main(Native Method)
08-29 05:21:58.843: I/Process(1934): Sending signal. PID: 1934 SIG: 9

MainActivity.java Code:

package com.example.androidfirst;

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);
    }
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.androidfirst"
    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>

I would be very thankful to you people!

Lahori
  • 1,071
  • 11
  • 20
  • Have you used appcomapct_v7 library project for your project?? – Piyush Aug 29 '14 at 05:57
  • In your manifest try change "targetSdkVersion" to 20 or something lower(incase its a preview thing) – PrivatMamtora Aug 29 '14 at 05:58
  • Check this answers http://stackoverflow.com/questions/17851783/error-implementing-support-library-action-bar & http://stackoverflow.com/questions/20900832/java-lang-noclassdeffounderror-android-support-v7-appcompat-rstyleable – The Heist Aug 29 '14 at 06:07
  • @PiYusHGuPtA yes it is created by default! – Lahori Aug 29 '14 at 06:19
  • @user2091552 I know that but just check that is it in ur project with Green mark in Android option?? – Piyush Aug 29 '14 at 06:21
  • @PrivatMamtora i changed it to 19 & now i get this error "Failed to install AndroidFirst.apk on device 'emulator-5554': timeout Launch canceled!" – Lahori Aug 29 '14 at 06:21
  • @PiYusHGuPtA i 'm sorry but i can't follow you! if you could elaborate me with steps to follow then i may tell you! – Lahori Aug 29 '14 at 06:32
  • @user2091552 what apk version is your emulator, if L/21 switch to 19 or so – PrivatMamtora Aug 29 '14 at 06:38
  • @PrivatMamtora where to locate this apk version? i am totally new that's why i don't know much about Android... – Lahori Aug 29 '14 at 06:52
  • @user2091552 open avd manager and view the vd's properties, for more search on how to use avd manager – PrivatMamtora Aug 29 '14 at 07:03
  • @PrivatMamtora Ok! the "Target" drop-down menu shows "Android 4.4W-API Level20" & CPU/ABI shows "Android Wear Intel Atom (x86)" – Lahori Aug 29 '14 at 07:29
  • @user2091552 On a side note did you try this http://stackoverflow.com/a/21898031/3922891 – PrivatMamtora Aug 29 '14 at 07:53

2 Answers2

1

For that Android Support library is required

See this image:

enter image description here

Then just import the v7 compact library project into your work space and add it as a library to your project

you can find it in sdk\extras\android\support\v7\appcompat where your SDK is present in directory.

After importing, select your project right click ->Properties-> Android->Add->Select app compact

click ok.

Sufian
  • 6,405
  • 16
  • 66
  • 120
Nikhilesh Patve
  • 1,760
  • 3
  • 13
  • 31
  • all you tell, is already done. Upon your recommendation, i followed the same & i can see it there i.e. support library is installed & added to my project! – Lahori Aug 29 '14 at 06:30
0

The problem resolve when i downloaded API-19 & re-created the AVD. On a very first attempt, the AVD shows "Hello World" the default text on emulator.

Lahori
  • 1,071
  • 11
  • 20