Programming

Android Studio에서 갑자기 기호를 확인할 수 없습니다

procodes 2020. 5. 8. 21:37
반응형

Android Studio에서 갑자기 기호를 확인할 수 없습니다


Android Studio 0.4.2는 정상적으로 작동했으며 오늘 열었고 거의 모든 것이 빨간색이었고 자동 완성 기능이 작동하지 않았습니다. 수입품을보고 AS 가 갑자기 android.support.v4를 찾을 수 없다고 말하고있는 것 같습니다 (사용하지 않는 수입품을 제거하는 옵션을 제공합니다). ( android.support.v7 은 괜찮은 것 같습니다).

내가 시도한 것 :

  • 프로젝트 재건
  • 프로젝트 청소
  • Gradle 파일과 동기화
  • 프로젝트 마감, AS 마감 및 재실행 / 재 개설
  • 파일> 캐시 무효화 / 재시작
  • 린트 검사 중, 명백한 것이 보이지 않았습니다.
  • SDK 관리자에서 모든 지원 라이브러리가 최신 상태인지 다시 확인
  • 내 Build.gradle을 검사하면 변경 사항이 없으며 평소와 동일하지만 항상 작동하는 방식입니다.

관련이있는 경우 :

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.0'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.android.support:gridlayout-v7:19.0.0'
    compile 'com.android.support:appcompat-v7:19.0.0'
    compile 'com.google.android.gms:play-services:4.0.30'
    compile project(':libraries:facebook')
    compile files('libs/core.jar')
}

"그라들과 동기화"를 누르고 "프로젝트 설정"을 열면 라이브러리 참조가 중복되어 사용하지 않는 라이브러리를 제거하라는 빨간색 오류가 발생합니다. 여기에 이미지 설명을 입력하십시오

내 프로젝트는 컴파일되고 잘 실행되지만 실제로 자동 완성 작업이 필요합니다 !! 누구든지 제안이 있습니까?

여기에 이미지 설명을 입력하십시오


당신은 이미 도움이 될만한 것들의 목록을 내려 왔지만 시도해 볼 수 있습니다 :

  • Android Studio 종료
  • 프로젝트 백업
  • 모든 .iml 파일과 .idea 폴더를 삭제하십시오.
  • Android Studio를 다시 시작하고 프로젝트를 다시 가져 오십시오.

그건 그렇고, 프로젝트 구조 대화 상자에 표시되는 오류 메시지는 대부분 가짜입니다.

최신 정보:

Android Studio 0.4.3 is available in the canary update channel, and should hopefully solve most of these issues. There may be some lingering problems; if you see them in 0.4.3, let us know, and try to give us a reliable set of steps to reproduce so we can ensure we've taken care of all code paths.


None of the things mentioned earlier here did actually work for me. But then I found this menu entry in the file menu Invalidate Caches/Restart which appears to have fixed the problem.

I don't really know what happened in the background but when Android Studio started up again the status bar said Indexing... for a minute or so which apparently did wonders.

For reference I'm using Android Studio 0.5.4.


Go through the link and it worked for me.

1.) Choose File option from menu on left top side of android studio.

2.) Select the option : "Invalidate Cache/ Restart.." It will open an dialog.

3.) Click on the first button with option : "Invalidate and Restart"

4.) It will close the studio and restart it. Start indexing of the project.

It resolved my problem:

File -> Invalidate Cache/ Restart -> Invalidate and Restart

Source: https://www.youtube.com/watch?v=FX_gCTpqhwM


Android Studio 1.3

  1. Open Module Settings
  2. Click on your module under Modules menu
  3. In the properties tab, set the Source Compatibility and Target Compatibility to your java version.

I did nothing else and it worked for me.


For me it was a "progaurd" build entry in my build.gradle. I removed the entire build section, then did a re-sync and problem solved.


There is a far easier solution built into Android Studio, and it usually works for me without needing any brute force solution mentioned in other answers - so you should try this first: 여기에 이미지 설명을 입력하십시오

click on the "gradle" symbol on the right side of Android Studio, and then on the "Refresh all Gradle projects" tool.


I'm using Android Studio 3.1.4 and I was experiencing such issue when moving from my develop branch with a lower api target to another branch with target api Oreo. I tried the first solution which worked but it is quite tricky, while the second solution did not solve the problem.

My Solution When the problem popped back again I have tried to modify slightly my app gradle file enough to AS to ask me to sync files, and that did the trick. Then I deleted the change.

I guess that "Sync Project with Gradle Files" might work as well but I haven't tried it myself

Hope it helps


Thought i'd throw this out there too:

the thing that worked for me was changing my build variant back to a variant that was working previously. For some reason i had changed this before (and i forgot why).

either way, the best thing to do is to try to remember what you changed that day (it could be something as minor as cleaning, or going back to a previous git commit)...etc.

it also helps to try to resync gradle and force a rebuild.


Struggled with the same problem for a couple hours this morning. Building my project from command line seems to have done the trick for me.

Exact steps -

  1. Cloned fresh repository (no Android studio files are in repo)
  2. Built debug project from command line ( ./gradlew clean assembleDebug )
  3. Open Android Studio, import project

To check if it worked, look in your projects exploded-bundles folder, inspect a library and find the classes.jar. If it is expandable, then everything is going to be ok.

edit - I found after doing a clean within Android studio, it broke again. So if you have to clean, you will need to do this process again.


None of these methods helped me in Android Studio 0.5.8.

My solution was to delete ~/.AndroidStudioPreview directory (in Ubuntu). Sorry, I have no idea where is it in other OS. This directory stores temporary files and Android Studio settings, so I missed all my settings. But it works!


Another way is to download JDK 1.7 and change the path from Android Studio in the error message..and choose Home folder who is contained in Jdk 1.7 folder


Got the same problem today. Fixed it by changing the jdk location in the project structure from \java\jdk1.7.0_05 to \java\jdk1.7.0_25 (which I didn´t know existed until now).

I´m using Android Studio 0.8.6.


I fixed this by removing the settings.gradle from my module subproject. It's a Java Gradle project with it's own settings.gradle file that somehow it screws it up.

Thanks to this guy: https://stackoverflow.com/a/33978721/425238


I tried cleaning the project and then invalidating the cache, neither of which worked. What worked for me was to comment out all my dependencies in build.gradle (app), then sync, then uncomment the dependencies again, then sync again. Bob's your uncle.


I faced similar problem but I followed following steps in my case :-

1).inside project under .idea folder open modules.xml. 2).check if there are two entries for same iml file. 3).delete one of duplicate entry and close android studio or build gradle file again.

In my case it worked. Hope it helps


I got it solved by setting JDK. I got a pop up saying that Setup JDK when I placed mouse over the error.


I had the same problem, none of the solutions listed here worked. The problem was my source files where not inside the right folder.

The directory structure MUST be :

[project]\[module]\src\main\java\[yourpackage]\[yourclass.java]


I have finally figured out what causes this issue.

Actually, you should avoid pushing .idea/libraries folder to your repository. It creates weird stuff in Android Studio which tends to remove all downloaded libraries.

If you have commit history, just recreate all missing library files and avoid them to be committed again. Otherwise, just remove whole .idea folder and reimport it into AS.


try to change your build.gradle with these value:

android { compileSdkVersion 18 buildToolsVersion '21.0.1'

defaultConfig {
    minSdkVersion 18
    targetSdkVersion 18
}

I use shared preferences, but Android Studio complained about Editor symbol. Then, I added

import android.content.SharedPreferences.Editor;

and symbol is cool now.


Please check if you have a project path which has special characters like ! (exclamation mark).

In a similar problem that I experienced, this was the root cause - since many Java applications seem not to tolerate such special characters (For e.g. doing a 'gradlew clean' from the terminal would fail and throw a RunTimeException.). None of the other solutions posted online had helped me. But, once I had removed the ! from the path and did a clean build, Android Studio magically worked.


I tried everything listed here. Then I checked my androidmanifest.xml I'd had some stoopid mismatched due to folder renames & package renames.


In my multi-module project, the problem was that version of "com.android.support:appcompat-v7" in module A was "22.0.0", but in B - "22.2.0".

Solution: make sure
1. version of common libraries is same among modules.
2. each of modules compiles without any errors (try to build each of them from CLI).


Be aware that the name of files and specially folders can result in this error. For instance, if you have a folder "Helpers" and the package for files in this folder is "com.whatever.helpers" it won't result in any compilation error but will cause the Android studio fail to load the symbols in that folder. One typical reason for that is when you name a folder with first capital letter, commit it on Git and later change the folder name to all lower case. The Git system won't recognize the change resulting in a discrepancy between the local and remote repositories that only the new repository clones will be affect by.


Another very subtle cause:

Multi-flavor library should be compiled in specific way than a normal single-flavored. Otherwise it silently produces cannot resolve symbols error.

Multi flavor app based on multi flavor library in Android Gradle


I had a much stranger solution. In case anyone runs into this, it's worth double checking your gradle file. It turns out that as I was cloning this git and gradle was runnning, it deleted one line from my build.gradle (app) file.

dependencies {
     provided files(providedFiles)

Obviously the problem here was to just add it back and re-sync with gradle.


I had a similar problem when I rebuilt an aar file and replaced the older one in my project with the new one. I went through all the solutions here and none solved my issue. I later realised that minifyEnabled had been set to true in the library project which effectively removed a lot of dead code that was not being used in the library project.

내 솔루션은 라이브러리 프로젝트에서 minifyEnabled를 false로 설정하고 aar를 어셈블하여 프로젝트에 복사하고 캐시를 무효화하고 등급 프로젝트를 동기화하여 모든 것이 잘 작동하는 것이 었습니다.

참고 URL : https://stackoverflow.com/questions/21100688/android-studio-suddenly-cannot-resolve-symbols

반응형