• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Cannot resolve symbol

LV67

Lurker
I followed the tutorial from Android Studio to make my first App.

On this page is explained to 'Create a second activity'.
https://developer.android.com/training/basics/firstapp/starting-activity.html

I think I followed everything like explained but got a still a few errors.

In this part of code I got an error
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);

ViewGroup layout = (ViewGroup) findViewById(R.id.activity_display_message);
layout.addView(textView);

I got an error : Cannot resolve symbol for the SetTextSize, SetText and addView. In an earlier part of the tutorial is following explained :

Android Studio will display Cannot resolve symbol errors because this code references classes that are not imported. You can solve some of these with Android Studio's "import class" functionality by pressing Alt + Enter (or Option + Return on Mac).

For earlier errors I solved the problem like mentioned but for those I don't see the possibility to import the class.

How do I solve this problem.
 
Please post your code. The whole class, not just a small code fragment. Use [code][/code] tags.

Also check that you have the following import statement

Code:
import android.widget.TextView;
 
Also, what is in your build.gradle file? You may have a missing dependency.
 
Back
Top Bottom