Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Newbie with a broken Crystal Ball

So I've been enjoying making the crystal ball as part of the introduction to android track, and I got to the point where we learn to put an image behind the button we've created. After doing this. I tried to test mine out only to get the "crystal ball has closed" error upon starting it.

After a while of trying to find the problem I gave up and downloaded the project files provided by treehouse. After importing these files and trying to carry on from that point, I have 1700ish errors listed when trying to run the app! a lot of these are things which 'cannot be resolved to a type' . I was really enjoying the course but am no longer able to continue unless i figure out what's gone wrong! I assume I have made a fundamental and obvious mistake as there are just so many errors..

Any help would be warmly appreciated!

Thanks!

Baruch Yochai
Baruch Yochai
4,624 Points

I have the same problem!(((

5 Answers

Nick Edwards
PLUS
Nick Edwards
Courses Plus Student 15,766 Points

Hi Mathew,

Could you post the contents of MainActivity.java, activity_main.xml and the LogCat (it should appear as a tab at the bottom of Eclipse).

The LogCat should display any errors that arise when you emulate your app.

Don't forget to use Markdown to format your code so it's easier to read :)

Thanks Nick!

Mainactivity.java: ''' package com.example.crystalball;

import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView;

public class MainActivity extends Activity {

private CrystalBall mCrystalBall = new CrystalBall();

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

    // Declare our View variables and assign them the Views from the layout file
    final TextView answerLabel = (TextView) findViewById(R.id.textView1);
    Button getAnswerButton = (Button) findViewById(R.id.button1);

    getAnswerButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String answer = mCrystalBall.getAnAnswer();

            // Update the label with our dynamic answer
            answerLabel.setText(answer);
        }
    });
}


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

} '''

Activity_main.xml : '''<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.crystalball.MainActivity$PlaceholderFragment" android:background="@android:color/black" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitCenter"
    android:src="@drawable/ball01" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:textSize="32sp" />

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:text="Enlighten me!" />

</RelativeLayout> '''

I can't find a way to display the logcat file :( I can paste the error log from the "problems" view but there's a lot...

Nick Edwards
Nick Edwards
Courses Plus Student 15,766 Points

Perhaps you could select everything in the problems window, copy and paste it into a text file, and upload it somewhere?

Also, in case it's an issue with themes, could you paste your AndroidManifest.xml?

Baruch Yochai
Baruch Yochai
4,624 Points

I did everything 100% as our teacher Ben did in this course till this stage, and also got the same problem. I think Ben need to explain us...and it is probably problem from the lesson.

Baruch Yochai
Baruch Yochai
4,624 Points

https://teamtreehouse.com/forum/same-code-different-models-different-screens

May be it will help. Also here http://teamtreehouse.com/library/build-a-simple-android-app/pretty-little-things/adding-an-image-2 under the video, you can notice the Theme error issues from the teacher.

If you solve the problem please, reply me also.