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


activity_main cannot be resolved or is not a fiel

i keep receiving that error . here is my Main activity package com.example.magicball;

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

public class MainActivity extends Activity { private crystallball mcrystallball = new crystallball(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_item); final TextView answerLabel = (TextView) findViewById(R.id.textView1); Button getAnswerButton = (Button) findViewById(R.id.button1); getAnswerButton.setOnClickListener(new View.OnClickListener() {

    public void onClick(View arg0) {
    String answer = mcrystallball.getAnAnswer();


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;

} Maybe it has something to do with my layout, here is the code
<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" />

    android:text="tell me" />

1 Answer

Rafael Moreno
Rafael Moreno
17,345 Points

That happened to me, add it to your R.java file. Just hover over the error message and the intellisense will pop up with that option.