Android Studio 3.1 Cannot Resolve Symbol (Themes, Widget, attr, etc.)

220
March 28, 2018, at 11:35 AM

I upgraded Android Studio today to 3.1, and now Android Studio says it cannot resolve symbols for most of the resources (for example ThemeOverlay in styles.xml or ?attr/actionBarSize). This doesn't seem to prevent me from building or running in an emulator so far, but these errors are making me nervous.

Has anyone else experienced this issue? How can I go about resolving it? I have tried syncing gradle and cleaning my project but it doesn't seem to help at all.

Any ideas?

I'm using Android Studio 3.1 with Gradle version 4.4 and Gradle Plugin 3.1.0

Answer 1

After upgrading Android Studio you can invalidate caché and restart

File > Invalidate Cache / Restart

Answer 2

For some reason, those attributes are not found anymore in the 26 libraries. For increasing those libraries you have to also increase your compileSdk to 27. It is probable you will also have to download the sdk 27

Short version, following goes on the app `graddle``

android {
    compileSdkVersion 27
    //...
}
dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    //...
}

Long version, check all following files:

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

build.gradle (Project)

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

And finally build.gradle (app)

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "cl.cutiko.testingupdate"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Answer 3

@JPM you can try to do this steps

./gradlew clean plugin-studio3.0:buildPlugin should do it, the plugin will be at plugin-studio3.0/build/distributions.

References - Android Studio 3.1 Canary 9

READ ALSO
A zoomable and extendable/expandable larga surface for Android

A zoomable and extendable/expandable larga surface for Android

I'm working on a Flowchart drawing tool for Android and I need a surface to draw on, like a layout or viewOf course, it needs to be able to expand itself in all four directions as user adds more and more shapes

76
Mobile app permission control using cordova plugin(s)

Mobile app permission control using cordova plugin(s)

My apps require several app permissions on iOS and an Android, for example the camera and microphoneWe want to maximize the chances that these permissions are granted

139
React-native add a widget to the android home screen

React-native add a widget to the android home screen

I have the following code: https://githubcom/lucas-kejan/React-Widget/blob/master/android/app/src/main/java/com/androidwidgetpoc/BackgroundTaskBridge

99
why RecycleView items is not displayed?

why RecycleView items is not displayed?

I have a problemWhen I use newsPojo at first - all displayed ok (but swipe to refresh is not work, when I use postAdapter

79