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

问题: 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/act...

问题:

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


回答1:

Close the project and import it again. Worked for me today.


回答2:

After upgrading Android Studio you can invalidate caché and restart

File > Invalidate Cache / Restart

introducir la descripción de la imagen aquí


回答3:

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'
}

回答4:

@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

  • 发表于 2018-03-29 14:44
  • 阅读 ( 1347 )
  • 分类:sof

0 条评论

请先 登录 后评论
不写代码的码农
网文小编

0 篇文章

作家榜 »

  1. 网文小编 0 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除