Android Studio - Cannot Resolve Symbol 'R'

2.8k views Asked by At

This question has been asked many times before, but i have tried everything and nothing has worked. Cleaning, Rebuilding, Syncing Gradle, Editing XML.

I get the error "Cannot resolve symbol 'R'" on every file the has 'R.blah.blah' in it.

This is a line of code where the error shows up.

int gray = getResources().getColor(R.color.card_gray);

Does anyone have any idea why this is happening? I've tried restarting which hasn't worked, so I'm thinking it's a bug in the current Android Studio version.

EDIT: Android Manifest and beginning of Java file (one of the affected ones)

I have 3 manifests, one for each module (CardsUI, Silk, App), I'm making an icon pack. The error is happening in all 3 modules.

App:

Too long to post, so here is a Gist: App Manifest

CardsUI:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.afollestad.cardsui"
      android:versionCode="1"
      android:versionName="1.0">

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="18"/>

</manifest>

Silk:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.afollestad.silk"
      android:versionCode="1"
      android:versionName="0.1">

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19"/>

<application/>
<!-- required to build aar. -->

</manifest>

Example start of affected CardsUI file:

package com.afollestad.cardsui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;

EDIT 2: Tried creating new project and importing files, and I get the same thing. This is getting really annoying now.... Please help someone!

Thanks

2

There are 2 answers

2
Andrew On

It could be if you have deleted

<string name="action_settings">Settings</string>

in the strings.xml, but not deleted main.xml file in the menu folder.

0
fuuuh cghh On

You can try what is described in the images below:

enter image description here enter image description here