Program Club

Android Studio 3.1에서 기호 (테마, 위젯, 속성 등)를 확인할 수 없습니다.

proclub 2020. 11. 12. 20:29
반응형

Android Studio 3.1에서 기호 (테마, 위젯, 속성 등)를 확인할 수 없습니다.


오늘 Android Studio를 3.1로 업그레이드 ThemeOverlay했는데 이제 Android Studio에서 대부분의 리소스 (예 : styles.xml또는 ?attr/actionBarSize)에 대한 기호를 확인할 수 없다고 말합니다 . 이것은 지금까지 에뮬레이터에서 빌드하거나 실행하는 것을 방해하지 않는 것 같지만 이러한 오류로 인해 긴장됩니다.

다른 사람이이 문제를 경험 한 적이 있습니까? 어떻게 해결할 수 있습니까? 나는 gradle을 동기화하고 내 프로젝트를 청소하려고 시도했지만 전혀 도움이되지 않는 것 같습니다.

어떤 아이디어?

Gradle 버전 4.4 및 Gradle 플러그인 3.1.0과 함께 Android Studio 3.1을 사용하고 있습니다.

수정 : 이 문제는 Android Studio 3.1.1, 3.1.2, 3.1.3, 3.1.4 및 Gradle 플러그인을 3.1.1, 3.1.2, 3.1.3 및 3.1.4로 업데이트하는 데 영향을줍니다. 그러나 아래 답변은 여전히 ​​작동합니다.


프로젝트를 닫고 다시 가져옵니다. 오늘 나를 위해 일했습니다.

수입 프로젝트


프로젝트를 기존 Android Studio 프로젝트로 닫았다가 다시 엽니 다.


지원 라이브러리가 동기화되지 않았습니다.

이 오류는 지원 라이브러리가 프로젝트와 동기화되지 않기 때문에 발생합니다. 다시 동기화하려면 다음 단계를 수행하십시오.

  1. 앱 모듈의 build.gradle 파일을 엽니 다.
  2. implementation지원 라이브러리에 대한 줄을 주석으로 처리하십시오 . 나에게는 다음과 같이 보입니다.

    //implementation 'com.android.support:appcompat-v7:27.1.1'
    //implementation 'com.android.support:recyclerview-v7:27.1.1'
    //implementation 'com.android.support.constraint:constraint-la
    
  3. 프로젝트를 gradle과 동기화하십시오. 이제 약간의 오류가 있습니다. 그것에 대해 걱정하지 마십시오.

  4. implementation이전에 주석 처리 한 줄의 주석 처리를 제거하십시오 .

    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-la
    
  5. 프로젝트를 gradle과 다시 동기화하십시오.

이제 "기호를 해결할 수 없음"오류가 사라졌습니다. 이것은 다른 프로젝트에서 여러 번 저에게 효과적이었습니다.

노트

  • 프로젝트에 여러 모듈이있는 경우 한 번에 모든 모듈에 대해 위의 지침을 따라야합니다.

Android Studio를 업그레이드 한 후 캐시를 무효화하고 다시 시작할 수 있습니다.

File > Invalidate Caches / Restart…

la descripción de la imagen aquí 소개


어떤 이유로 이러한 속성은 26 개 라이브러리에서 더 이상 찾을 수 없습니다. 이러한 라이브러리를 늘리려면 compileSdk27으로 늘려야합니다 . sdk 27을 다운로드해야 할 수도 있습니다.

짧은 버전, 다음은 앱 'graddle'로 이동합니다.

android {
    compileSdkVersion 27
    //...
}

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

긴 버전, 다음 파일을 모두 확인하십시오.

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 (프로젝트)

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
}

마지막으로 build.gradle (앱)

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

프로젝트를 닫고 기존 프로젝트로 여는 것은 놀라운 일입니다!


프로젝트를 다시 가져 오는 것만으로는 효과가 없었습니다.

내 해결책은

  1. .idea프로젝트 내의 폴더를 삭제 하십시오.
  2. 그런 다음 프로젝트를 닫습니다. File> Close Project
  3. 그런 다음 시작 화면에서 OR프로젝트를 가져옵니다 .File> New > Import Project Import Project (Gradle, Eclipse ADT, etc.)

자세한 내용은 스크린 샷 참조

첫 번째 솔루션

또는

두 번째 솔루션


프로젝트를 닫고 Android Studio를 종료 할 수 있습니다 (닫았다가 다시 가져 오면 나에게 도움이되지 않습니다). Android Studio를 시작하고 프로젝트를 다시 엽니 다. 그것은 나를 위해 일했습니다!


기존 Android Studio 프로젝트 (가져 오지 않음)로 프로젝트를 닫았다가 다시 열었고 작동했습니다! Andrew Glukhoff 의 의견에 감사드립니다 .


implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:26.1.0'

build.gradle (project)에서 위의 종속성을 업데이트하십시오.

아래 코드를 build.gradle (Module : app)

classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'io.realm:realm-gradle-plugin:3.7.1'
classpath 'com.google.gms:google-services:3.1.0'

나에게 동일한 증상 / 오류는 예를 들어 이름에 숫자 또는 대문자가있는 Android Studio가 좋아하지 않는 이름으로 새 이미지를 'drawable-xxhdpi'폴더로 끌어서 놓아서 발생했습니다.

No useful error message was given just the 'cannot resolve symbol R' message.

Even after synching the app and cleaning and rebuilding project, the issue remained that 'R' was not recognised with no other error indicated.

Closing and importing the project as suggested in other answers did not work, which makes sense given the root problem.

However, even though it appears this has not worked for others in the past, judging by other questions and answers on SO, deleting the new image from the drawable folder did work.

Similarly, and a better solution, obviously, renaming the image to remove any characters that Android does not like in resource names and then doing a clean and/or rebuild project also worked.


Problem #1

My problem was related with how I used an alpha/beta version of Android Plugin

File > Project Structure > Project

check your Android Plugin Version

I was using something called 3.3.0-beta, and yet in another project 3.1.0-alpha

changing it to 3.2.0 seems to clear up my issue, don't forget to change the one in build.gradle(Project) too

Problem #2

I had an error in one of my .xml files. I missed a @string resource. Please check all your xml files, and make sure they are all correct (opening an xml file should activate Android Studio linting, scroll through the file, it should complain in red if something is wrong)

Problem #3

In build.gradle I imported different versions of the android support libraries. e.g.

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:27.1.0'

Please make sure they are the same version. And make sure that Android Studio doesn't complain anything inside your gradle dependencies. It might be that some of your dependencies also imported different android support library versions.

Steps to take after #1, #2 and #3

Clean your project Build > Clean Project

Invalidate cache and restart File > Invalidate Caches / Restart

After restart, wait for gradle build to finish, then voila!


I updated my gradle version to 4.10.1 and did "fix and reimport". There were no libraries folder under .idea before. And then it worked


Similar error for me when I update to com.android.tools.build:gradle 3.3.1 and gradle-4.10.1

I have tried the following method but didn't work:

  1. Clean Project - Rebuild Project
  2. Invalidate Caches / Restart
  3. Check .xml error (I didn't find any errors about xml )
  4. Modify .iml file

나는 수정 하여이 오류를 수정 com.android.tools.build:gradle 3.2.1하고 Restart my mac어느 것이 그것을 고칠 수 있는지 몰랐지만 실제로는 나를 위해 작동합니다.


어떻게 해결했는지. :
해결 방법

Android 스튜디오를 버전 3.2로 업데이트했고 두 단계로이 문제를 해결했습니다.

  1. Android 스튜디오 시작 페이지에서 삭제되었습니다.

  2. 프로젝트를 다시 엽니 다.

나를 위해 일했습니다.


setContentView ( R .layout.activity_login_ativity);

  1. R에 커서를 놓습니다.
  2. Alt + Enter를 클릭합니다.
  3. 수입 등급 R 선택

나를 위해 일하십시오 :)

참고 URL : https://stackoverflow.com/questions/49523302/android-studio-3-1-cannot-resolve-symbol-themes-widget-attr-etc

반응형