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

Android Build a Simple Android App with Java Basic Android Programming Making a Button Do Something

I am having an error message every time I try to test the click button function

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details. Error:(20, 52) error: cannot find symbol variable factTextView

i have tried using Alt + Enter method. But is not working.

Pliz help

2 Answers

Charles Wanjohi
Charles Wanjohi
9,235 Points

Do you have a variable named factTextView in your code? Note the spelling should be exact e.g facttextView or facttextview is completely different.You should have shared your code for a better help

I didn't manage to upload the screen shot

I seem to be having the same problem. When I press alt+enter I'm not given the option to cast, how is this happening?

public class FunFactsActivity extends AppCompatActivity {
    // Declare our view variables
    private TextView factTextView;
    private Button showFactButton;

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

        // Assign the Views from the layout file to the corresponding variables
        factTextView = findViewById(R.id.factTextView);