안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요. Android초보 입니다.
res->drawble-hdpi 폴더에 이미지를 copy하면 자동으로 R.java 파일에 final로 이미지가 선언 되는 걸로 알고 있습니다.
이후에 제가 이 이미지 아이콘을 알림창에 띄우고 싶을 경우 R.drawble.이미지파일 이름 이런식으로 접근해서 사용하고 싶은데 에러가 나네요
혹시 이 작업 말고 다른걸 또 해줘야 하나고?xml도 추가 해야 한다던지 이런거요..찾아봐도 몰라서 도움을 구합니다.
답변 부탁드립니다.
2012.11.23 13:04:58
다른거 안 하셔도 됩니다.
Build가 안된걸 수도 있으니 Clean 한 번 해보세요.
아니면 android.R 클래스가 import 된걸 수도 있으니 import 구문을 확인해보시고 android.R 어쩌구가 있으면 지우고 다시 import 해보세요.
2012.11.23 14:06:08
android가 아닌 앱의 R입니다.
import com.playmaroo.cattown.R;와 같이 import트 하엿구요 아래는
오류시 생기는 LogCat입니다..뭐가 문제일 까요.........휴
11-23 14:02:33.613: W/ResourceType(235): getEntry failing because entryIndex 2 is beyond type entryCount 1
11-23 14:02:33.613: W/ResourceType(235): Failure getting entry for 0x7f020002 (t=1 e=2) in package 0 (error -2147483647)
11-23 14:02:33.617: W/ImageView(235): Unable to find resource: 2130837506
11-23 14:02:33.617: W/ImageView(235): android.content.res.Resources$NotFoundException: Resource ID #0x7f020002
11-23 14:02:33.617: W/ImageView(235): at android.content.res.Resources.getValue(Resources.java:892)
11-23 14:02:33.617: W/ImageView(235): at android.content.res.Resources.getDrawable(Resources.java:580)
11-23 14:02:33.617: W/ImageView(235): at android.widget.ImageView.resolveUri(ImageView.java:501)
11-23 14:02:33.617: W/ImageView(235): at android.widget.ImageView.setImageResource(ImageView.java:280)
11-23 14:02:33.617: W/ImageView(235): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 14:02:33.617: W/ImageView(235): at java.lang.reflect.Method.invoke(Method.java:507)
11-23 14:02:33.617: W/ImageView(235): at android.widget.RemoteViews$ReflectionAction.apply(RemoteViews.java:808)
11-23 14:02:33.617: W/ImageView(235): at android.widget.RemoteViews.performApply(RemoteViews.java:1328)
11-23 14:02:33.617: W/ImageView(235): at android.widget.RemoteViews.apply(RemoteViews.java:1305)
11-23 14:02:33.617: W/ImageView(235): at com.android.systemui.statusbar.StatusBarService.makeNotificationView(StatusBarService.java:624)
11-23 14:02:33.617: W/ImageView(235): at com.android.systemui.statusbar.StatusBarService.addNotificationViews(StatusBarService.java:661)
11-23 14:02:33.617: W/ImageView(235): at com.android.systemui.statusbar.StatusBarService.addNotification(StatusBarService.java:458)
11-23 14:02:33.617: W/ImageView(235): at com.android.systemui.statusbar.CommandQueue$H.handleMessage(CommandQueue.java:233)
11-23 14:02:33.617: W/ImageView(235): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 14:02:33.617: W/ImageView(235): at android.os.Looper.loop(Looper.java:130)
11-23 14:02:33.617: W/ImageView(235): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-23 14:02:33.617: W/ImageView(235): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 14:02:33.617: W/ImageView(235): at java.lang.reflect.Method.invoke(Method.java:507)
11-23 14:02:33.617: W/ImageView(235): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
11-23 14:02:33.617: W/ImageView(235): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
11-23 14:02:33.617: W/ImageView(235): at dalvik.system.NativeStart.main(Native Method)
11-23 14:02:33.621: W/ResourceType(235): getEntry failing because entryIndex 2 is beyond type entryCount 1
11-23 14:02:33.621: W/ResourceType(235): Failure getting entry for 0x7f020002 (t=1 e=2) in package 0 (error -2147483647)
11-23 14:02:33.621: W/StatusBarService(235): Icon not found in 2130837506: 7f020002
11-23 14:02:33.621: W/StatusBarService(235): No icon for slot com.playmaroo.cattown/0x0
11-23 14:02:33.621: W/StatusBarService(235): removeNotification for unknown key: android.os.BinderProxy@4053b9b0
11-23 14:02:33.621: D/NotificationService(135): onNotification error pkg=com.playmaroo.cattown tag=null id=0; will crashApplication(uid=10096, pid=24321)
11-23 14:02:33.625: D/AndroidRuntime(24321): Shutting down VM
11-23 14:02:33.625: W/dalvikvm(24321): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
11-23 14:02:33.625: W/StatusBarService(235): removeNotification for unknown key: android.os.BinderProxy@4053b9b0
11-23 14:02:33.625: E/AndroidRuntime(24321): FATAL EXCEPTION: main
11-23 14:02:33.625: E/AndroidRuntime(24321): android.app.RemoteServiceException: Bad notification posted from package com.playmaroo.cattown: Coulding create icon: StatusBarIcon(pkg=com.playmaroo.cattown id=0x7f020002 level=0 visible=true num=0 )
11-23 14:02:33.625: E/AndroidRuntime(24321): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1048)
11-23 14:02:33.625: E/AndroidRuntime(24321): at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 14:02:33.625: E/AndroidRuntime(24321): at android.os.Looper.loop(Looper.java:130)
11-23 14:02:33.625: E/AndroidRuntime(24321): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-23 14:02:33.625: E/AndroidRuntime(24321): at java.lang.reflect.Method.invokeNative(Native Method)
11-23 14:02:33.625: E/AndroidRuntime(24321): at java.lang.reflect.Method.invoke(Method.java:507)
11-23 14:02:33.625: E/AndroidRuntime(24321): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
11-23 14:02:33.625: E/AndroidRuntime(24321): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
11-23 14:02:33.625: E/AndroidRuntime(24321): at dalvik.system.NativeStart.main(Native Method)
11-23 14:02:33.628: E/(135): Dumpstate > /data/log/dumpstate_app_error
임포트된 R이
android.R인지..
앱의 R인지 확인해보세요...