ShadowFlame
ShadowFlame

Reputation: 3278

Android Studio - Cannot resolve symbol - Build works

today AndroidStudio started acting up, not being able to resolve android.support.vx symbols anymore.

What I did shortly before: trying to clean up my C drive, and erroneously deleting the .android folder, as well as moving my SDK folder.

Issues are had with

import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AlertDialog;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;

the relevant part in gradle:

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.0'
    defaultConfig {
        applicationId "not.for.public.eyes"
        minSdkVersion 23
        targetSdkVersion 25
        versionCode 1
        versionName "0.0.21"
        //versionNameSuffix '-TEST'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        /*jackOptions {
            enabled true
        }*/
    }

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    //        exclude group: 'com.android.support', module: 'support-annotations'
    //    })
    compile files('src/main/libs/eidlib.jar')

    compile 'com.android.support:appcompat-v7:25.3.1'

What I have tried to resolve the issue:

  1. clean gradle build
  2. reinstall android studio
  3. invalidate caches

it worked without issue untill just before, but now it shows red always. Weird thing though: build still works, run on connected device still works.

all help appreciated

Upvotes: 1

Views: 3348

Answers (2)

Sandip Kothari
Sandip Kothari

Reputation: 151

Invalidate cache and restart didn't work for me. removing and adding dependencies worked for me. 1: Removing all dependencies from app/build.gradle and Sync. 2: Add all again and Sync.

Upvotes: 0

ShadowFlame
ShadowFlame

Reputation: 3278

thanks to this post, I found the solution.

  1. clean build(Build menu)
  2. invalidate cache(no restart) (File Menu)
  3. remove .gradle and .idea folders (View Menu > Tool Windows > Project >> Project pane, somewhere at the top probably)
  4. restart Android Studio

Possibly you can finetune this, but this is what worked for me.

Upvotes: 2

Related Questions