Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App (retired 2014) Getting Started with Android Android Setup and the Crystal Ball Project

Errors while running Crystal Ball app

Hi, Following the video i tried running android crystal ball app and it fails. On emulator i am getting a message: Crystal ball stopped unfortunately and in log file i see following error message:

05-31 10:22:00.480: D/dalvikvm(1198): Not late-enabling CheckJNI (already on)
05-31 10:22:04.770: W/dalvikvm(1198): VFY: unable to resolve static field 1559 (ActionBarWindow) in Landroid/support/v7/appcompat/R$styleable;
05-31 10:22:04.770: D/dalvikvm(1198): VFY: replacing opcode 0x62 at 0x0004
05-31 10:22:04.840: D/AndroidRuntime(1198): Shutting down VM
05-31 10:22:04.840: W/dalvikvm(1198): threadid=1: thread exiting with uncaught exception (group=0xb1a65ba8)
05-31 10:22:05.320: E/AndroidRuntime(1198): FATAL EXCEPTION: main
05-31 10:22:05.320: E/AndroidRuntime(1198): Process: com.example.crystalball, PID: 1198
05-31 10:22:05.320: E/AndroidRuntime(1198): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at com.example.crystalball.MainActivity.onCreate(MainActivity.java:18)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.app.Activity.performCreate(Activity.java:5231)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.os.Handler.dispatchMessage(Handler.java:102)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.os.Looper.loop(Looper.java:136)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at android.app.ActivityThread.main(ActivityThread.java:5017)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at java.lang.reflect.Method.invokeNative(Native Method)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at java.lang.reflect.Method.invoke(Method.java:515)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-31 10:22:05.320: E/AndroidRuntime(1198):     at dalvik.system.NativeStart.main(Native Method)
05-31 10:23:01.570: I/Process(1198): Sending signal. PID: 1198 SIG: 9

Please answer: Ben Jakuben

3 Answers

From your logs I can only make the following comments, Following line says, something is wrong on line# 18 of your MainActivity class, check your code with tutorial code. There is always a link to working project code on the lower right bottom of the video tutorial (horizontally parallel to teacher's notes section), you can download that code, run it and cross verify with yours. ******Your logcat line**** 10:22:05.320: E/AndroidRuntime(1198): at com.example.crystalball.MainActivity.onCreate(MainActivity.java:18

The following line says something about class not found exception, maybe you have imported the wrong support library *******Logcat line***
E/AndroidRuntime(1198): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable

Hope this helps.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Can you paste in your MainActivity code and let us know which line is line 18?

package com.example.crystalball;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }


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

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            return rootView;
        }
    }

}

Ben Jakuben

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Something appears to have happened with how your project is using the appcompat_v7 library. This should be visible in your Package Explorer. Then you'll need to check if it's included as a library project in your Crystal Ball project. This answer on StackOverflow might help: http://stackoverflow.com/a/17853109/475217

As a side note, I am all set to record and refresh this course after Google I/O in a few weeks. The new version will not have this issue that was introduced by an Android Tools upgrade a few months ago. Sorry for your trouble!