티스토리 뷰

반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

package R does not exist

해당 패키지 R이 존재하지 않습니다.

 문제 내용 

I'm getting the dreaded package R does not exist, it's killing me. The code is fine I have apps in the market running the code.

R 패키지가 없다"는 오류가 발생해서 참 고민입니다. 코드는 괜찮은데 이미 시장에 출시된 앱들이 이 코드를 사용하고 있기 때문입니다.

 

Now it's effecting simple webview applications. o.0

이제는 간단한 웹뷰 애플리케이션에도 영향을 미치고 있습니다. o.0

 

R.string.app_name is error'd my main.xml and string.xml is fine. I'm sooo confused.

R.string.app_name에 오류가 있습니다. main.xml과 string.xml 파일은 정상입니다. 제가 너무 헷갈리네요.

 

I re opened an older version to "borrow" some code and it was flooded with R. errors. I did a clean and nothing changed except for import R.android being added at the top.

이전 버전을 다시 열어서 몇 가지 코드를 "빌리려"고 했더니 R. errors가 많이 발생했습니다. Clean을 실행해도 R.android import가 맨 위에 추가되었을 뿐 아무 변화도 없습니다.

 

I even loaded into Netbeans and I get the same thing. Clean is not working. Can I write the R.java file myself?

NetBeans와 같은 다른 IDE에서도 같은 오류가 발생하고 Clean 기능도 작동하지 않습니다. R.java 파일을 직접 작성할 수 있을까요?

 

What is this R thing? isn't R. supposed to correspond to R.java

이 R은 무엇입니까? R.은 R.java에 해당하지 않습니다.

 

 

 

 높은 점수를 받은 Solution 

For anyone who ran into this, I refactored by renaming the namespace folders. I just forgot to also edit AndroidManifest and that's why I got this error.

이 문제를 겪은 누구에게나, 저는 네임스페이스 폴더의 이름을 바꾸면서 리팩토링을 진행했습니다. 그런데 AndroidManifest도 수정해야하는데 그것을 깜빡해서 이 에러가 발생했습니다.

 

Make sure you check this as well.

이것도 확인해 주세요.

 

 

 

 가장 최근 달린 Solution 

This is how i solved it After several failed attempts of Build -> Clean Project followed by Build -> Rebuild Project

이렇게 해결했습니다. Build -> Clean Project를 시도한 후 Build -> Rebuild Project를 실행하는 것이 몇 차례 실패한 후에 이 문제를 해결할 수 있었습니다.

 

Step 0 : Made sure Package name is correct in AndroidManifest.xml in my case it was

단계 0: AndroidManifest.xml에서 패키지 이름이 올바른지 확인했습니다. 제 경우에는 다음과 같았습니다.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.myproject">  

 

Step 1 Place the cursor before myproject and press Shift + F6 -> Rename Package -> Give your new package name and under Scope select All Places -> Refactor

단계 1 : 커서를 'myproject' 앞에 놓고 Shift + F6을 누르세요. -> 패키지 이름 변경 -> 새 패키지 이름을 입력하고 범위에서 '모든 장소'를 선택하십시오. -> 리팩터링

 

Step 2 : Turn Off Auto Import

단계 2 : 자동 Import 기능 끄기

 

For Windows its File -> Settings -> Editor -> General -> Auto Import

윈도우의 경우, 파일(File) -> 설정(Settings) -> 편집기(Editor) -> 일반(General) -> 자동 가져오기(Auto Import)입니다.

 

Under Java

Java에 대한 것

 

uncheck Add unambiguous imports on the fly

Java에서 Add unambiguous imports on the fly 항목을 선택 해제합니다.

 

uncheck Optimize imports on the fly

uncheck Optimize imports on the fly: "Optimize imports on the fly"를 선택 해제하세요.

 

Apply and save

적용하고 저장하세요.

 

Step 3: Clean and Rebuild Build -> Clean Project followed by Build -> Rebuild Project

단계 3: Clean 및 Rebuild Build -> Clean Project를 실행한 다음 Build -> Rebuild Project를 실행합니다.

 

Now when you get the error during Build. Open the File that says R.java is missing or Cannot Find "R" class

이제 Build 중 오류가 발생하면 "R.java가 없거나 'R' 클래스를 찾을 수 없다"는 파일을 엽니다.

 

Step 4: Open the file and Go to its imports section in the code and add manually import com.example.myproject.R;

단계 4: 해당 파일을 열고 코드의 imports 섹션으로 이동한 다음 수동으로 import com.example.myproject.R;을 추가합니다.

 

Repeat the same for all the files mentioned in the Build Section that has this error

Build 섹션에 이 오류가 있는 모든 파일에 대해 동일한 작업을 반복하세요.

 

Clean and Rebuild and you are good to go !

Clean and Rebuild를 실행하면 문제가 해결됩니다!

 

 

 

출처 : https://stackoverflow.com/questions/12986301/package-r-does-not-exist

반응형
댓글
공지사항
최근에 올라온 글