developer tip

Android Studio에 잘못된 파일 내용이 표시됨

optionbox 2020. 11. 23. 08:02
반응형

Android Studio에 잘못된 파일 내용이 표시됨


Android Studio에 이상한 문제가 있습니다. 다음은 Android Studio에서 내 클래스 파일이 어떻게 보이는지입니다.

다음은 텍스트 편집기에서 보이는 모습입니다.

여기에 이미지 설명 입력

왜 그런 일이 발생하는지 아이디어가 있습니까? 프로젝트를 닫은 다음 다시 가져 와서 캐시를 무효화하고 다시 시작하고, 프로젝트를 정리하고, 프로젝트를 빌드하고, .idea 폴더 및 .iml 파일을 삭제하려고했습니다. 내 모든 파일은 AS에서 열 때 깨졌지만 텍스트 편집기에서는 괜찮아 보입니다.


업데이트 : 아래 주어진 사용자 Hong의 더 빠른 솔루션 :

캐시 폴더 삭제 : C : \ Users \ my_user_name \ .AndroidStudio3.3 \ system \ caches

=====================

여기에 저에게 효과적이었습니다.

  1. Android Studio 닫기
  2. C : \ Users * 사용자 이름 *으로 이동합니다.
  3. .AndroidStudioX.X (XX는 버전)라는 이름의 Android 스튜디오 설정 디렉토리를 찾습니다.
  4. old.AndroidStudioX.X와 같은 이름으로 이름을 바꿉니다.
  5. Android Studio를 시작하고 설정을 가져올 것인지 묻는 메시지가 나타나면 이전 디렉토리를 선택하십시오.

이렇게하면 문제가 해결됩니다.


Asim의 답변 덕분에 폴더 캐시를 삭제하면 문제가 해결되는 것으로 나타났습니다 (Android Studio의 모든 gradle 파일은 이러한 파일의 실제 내용과 관련이없는 내용을 표시 함).

C:\Users\my_user_name\.AndroidStudio3.3\system\caches

이 상황이 버그보고를 보증합니까?

예! 실제로이 문제는 Android Studio 팀보고 되었으며 조사에 도움을 주려는 사람은 누구나 참여할 수 있습니다. 감사!

Hong의 답변 에서 해결 방법을 시도 할 수도 있습니다 .


Thanks to @Henry for confirming, by several similarly observed whacko problems the past two days, that my problem is indeed caused by a bug in AS. Follow his links to become convinced yourself. I'll let Henry file the bug report.

So there's no fixing my problem in situ without great effort--wait for bug fix.... which could take awhile.

So here's what I did to work around it and get back to work (it took less than 10 minutes):

  1. create new project with no activity (Do the rest inside the IDE, not using Windows or DOS.)
  2. copy all .java files into the java folder in the IDE (it's ...\app\src\main\java\)
  3. copy all res folders into the res folder (...\app\src\main\res\)
  4. copy all asset files into main folder (...\app\src\main\assets\)
  5. copy androidmanifest.xml into main folder (...\app\src\main)
  6. do a global replace of old project name to new project name

I didn't change any of the files in the new project's ...\app\ folder because compilation was normal.

(I'll tell you this: when I saw what I THOUGHT were mangled FILES and looked at the History and saw nothing resembling what should have been there, I got a sick feeling, but I immediately opened Windows Explorer, selected all of the project's java files, and opened them, en masse, with Notepad++. Whew. No problems seen. (I didn't really think AS could actually mangle the files and I doubt it ever could. But it did wake me up at 5am!))


며칠 전에 내 안드로이드 스튜디오를 업데이트했고 같은 문제에 직면했습니다. Android 스튜디오를 제거하고 이전 버전 설정을 다시 설치하여 문제를 해결했습니다. SDK를 그대로 두었 기 때문에 다시 다운로드 할 필요가 없었기 때문에 곧 다시 업데이트하지 않을 것 같습니다.


플랫폼별로 아래 나열된 Android 스튜디오 IDE 캐시 데이터 를 삭제하십시오 .

  • Windows :
    %USER%\.AndroidStudio[Preview]_X.Y_
    
  • 맥:
    ~/Library/Preferences/AndroidStudio[Preview]_X.Y_
    
    ~/Library/Caches/AndroidStudio[Preview]_X.Y_
    
    ~/Library/Logs/AndroidStudio[Preview]_X.Y_
    
    ~/Library/Application Support/AndroidStudio[Preview]_X.Y_
    
  • 리눅스 :
    ~/.AndroidStudio[Preview]_X.Y_
    

참조 : https://developer.android.com/studio/releases#delete-unused


Android 프로젝트를 다른 위치에 복사 한 다음 Android 스튜디오에서 엽니 다.

참고 URL : https://stackoverflow.com/questions/53249677/android-studio-shows-wrong-file-contents

반응형