0

In my MainActivity.java file, I have no errors expect for one that shouldn't be there:

Cannot resolve symbol R

My imports are:

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.text.InputType;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;

Is there an import I am missing that enables R to work properly?

Munesawagi
  • 283
  • 1
  • 6
  • 14
  • 1
    Try Build > Clean Project – Shaishav Jul 26 '16 at 19:18
  • [Duplicate] marked with wrong question as that one mainly concerns Eclipse user and the OP has used android-studio tag. This seems more like it: http://stackoverflow.com/questions/17054000/cannot-resolve-symbol-r-in-android-studio?rq=1 – Shaishav Jul 26 '16 at 19:23
  • Make sure that the Gradle file is syncing correctly. – Jemil Riahi Jul 26 '16 at 19:23

1 Answers1

0

You can solve this problem by first "cleaning project" and then by opening "Tools" then "Android" and then "sync project with grade files"

If that doesn't work try importing the R class in the mainActivity class itself i.e.

Example: import com.example.androidproject.R;

Here you put your own project domain name and project name i.e. replace com.example with your domain name and androidproject with the project name...p.s. any problem comment below...

Tejas Mahajan
  • 43
  • 1
  • 9