开发者

Why am I getting "can't find view" exceptions when the layout hasn't changed?

开发者 https://www.devze.com 2023-01-31 10:41 出处:网络
I\'m working on one of my android widgets, which uses LauncherPlus to add scrolling functionality, and am running into a frustrating issue. My currently published version of the code, again using Laun

I'm working on one of my android widgets, which uses LauncherPlus to add scrolling functionality, and am running into a frustrating issue. My currently published version of the code, again using LauncherPlus, is working well, scrolling and all. I'm adding a requested feature, one which allows changing text sizes, but an exception is thrown when I test the update. There exception is:

mobi.intuitit.android.widget.SimpleRemoteViews$ActionException: can't find view:0x7f070041

I haven't changed anything in the layouts and the only code change references a view id which was already referenced in that same section of code. I looked through the R.java and found which resource was referred to and again, nothing has changed there. Here's the bit of code where the issue is coming from:

itemViews.setBoundBitmap(R.id.profile, "setImageBitmap", SonetProvider.SonetProviderColumns.profile.ordinal(), 0);
itemViews.setBoundCharSequence(R.id.friend, "setText", SonetProvider.SonetProviderColumns.friend.ordinal(), 0);
itemViews.setBoundCharSequence(R.id.created, "setText", SonetProvider.SonetProviderColumns.createdtext.ordinal(), 0);
itemViews.setBoundCharSequence(R.id.message, "setText", SonetProvider.SonetProviderColumns.message.ordinal(), 0);

The exception is thrown when applying the first line. Out of curiosity, I changed the order of these lines, and each one of them will cause the exception, though again, the layout hasn't changed. After the exception i开发者_如何学Cs thrown the widget will build successfully, but I can't publish this update with an exception (force close) being thrown. Any ideas why there is a resource issue? Thanks!

UPDATE: I found this discussion where it seems that widget resources may not be reloaded on application updates: http://groups.google.com/group/android-developers/browse_thread/thread/55a8e44974e8c6ad?fwc=1&pli=1 Does anyone have any experience with this, or a workaround? This may be what I'm facing.


Use Project > Clean in Eclipse or ant clean from the command line, then try again. Since resource IDs are integers, they are inlined in the bytecode of the classes that reference them, and so sometimes your pre-compiled classes can get out of sync with new resource IDs from a fresh compile. I work from the command line mostly, and I always tack clean onto my ant commands (e.g., ant clean install) to avoid this problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消