简体   繁体   English

当布局未更改时,为什么会出现“找不到视图”异常的情况?

[英]Why am I getting “can't find view” exceptions when the layout hasn't changed?

I'm working on one of my android widgets, which uses LauncherPlus to add scrolling functionality, and am running into a frustrating issue. 我正在使用其中一个Android小部件进行工作,该小部件使用LauncherPlus添加了滚动功能,并且遇到了令人沮丧的问题。 My currently published version of the code, again using LauncherPlus, is working well, scrolling and all. 我当前发布的代码版本,再次使用LauncherPlus,运行良好,可以滚动显示。 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. 我没有更改布局中的任何内容,唯一的代码更改引用了在同一代码段中已经引用的视图ID。 I looked through the R.java and found which resource was referred to and again, nothing has changed there. 我浏览了R.java,发现引用了哪个资源,再次没有改变。 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 is 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? 更新:我在这个讨论中发现似乎无法在应用程序更新时重新加载窗口小部件资源: http : //groups.google.com/group/android-developers/browse_thread/thread/55a8e44974e8c6ad? fwc=1&pli=1任何经验,或解决方法? This may be what I'm facing. 这可能就是我要面对的。

Use Project > Clean in Eclipse or ant clean from the command line, then try again. 在Eclipse中使用Project> Clean或从命令行使用ant clean ,然后重试。 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. 由于资源ID是整数,因此它们会内联在引用它们的类的字节码中,因此有时您的预编译类可能与新的编译中的新资源ID不同步。 I work from the command line mostly, and I always tack clean onto my ant commands (eg, ant clean install ) to avoid this problem. 我从大多在命令行工作,我总是粘性clean到我的ant命令(例如, ant clean install )来避免这一问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 游标中的数据未更改时刷新ListView的最佳方法 - Best way to refresh ListView when data in cursor hasn’t changed 无法弄清楚为什么我会遇到“未处理的处理程序” - can't figure out why i am getting “uncaught handler” 为什么我不能使用layout_toRightOf放置视图,而layout_alignParentRight =“ true” - Why I can't place view with layout_toRightOf the right of view with layout_alignParentRight=“true” 我不明白为什么我会收到此错误:android.view.InflateException: Binary XML 文件第 23 行在 com.whootis.hmmonitor: - I don't get why I am getting this error: android.view.InflateException: Binary XML file line #23 in com.whootis.hmmonitor:layout/activity_main Android:找不到所包含布局中的最外面的视图 - Android: Can't find outer most view inside included layout 为什么找不到我创建的 MainActivity.java 文件的布局? - Why can't i find the layout I have created my MainActivity.java file? 更新ActionBar的背景颜色时,为什么“图形布局”视图没有变化? - Why doesn't the Graphical Layout view change when I update the background color of my ActionBar? 为什么我不能在布局包含片段的情况下为布局充气? - Why I can't inflate a layout where the layout contains a fragment? 当我简单地做setContentView(R.layout.somelayout)时,为什么我会出现内存泄漏? - Why am I getting memory leakage when i am simpy doing setContentView(R.layout.somelayout)? 无法在布局中创建视图 - Can't create a view in layout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM