简体   繁体   English

Android Studio 2.3 Beta 1 +支持25.1.0 =预览已损坏

[英]Android Studio 2.3 Beta 1 + Support 25.1.0 = Preview broken

Android Studio 2.3 Canary 3. Support libraries 25.1.0. Android Studio 2.3 Canary 3.支持库25.1.0。

Layout previews are totally broken. 布局预览完全被打破。 Anything that contains a support-related View seems to break during preview. 包含支持相关视图的任何内容似乎在预览期间中断。

In all cases, this is the beginning of the stack: 在所有情况下,这是堆栈的开头:

Exception Details java.lang.NoSuchFieldError: ViewBackgroundHelper   
at android.support.v7.widget.AppCompatBackgroundHelper.loadFromAttributes(AppCompatBackgroundHelper.java:46)   
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:63)   
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:56)
....

.. Etc. ..等等

Doesn't matter what the layout is like, I'm now getting this bloody ViewBackgroundHelper -related issue come up. 无论布局是什么样的,我现在都会遇到这个血腥的ViewBackgroundHelper相关问题。 Doesn't seem to matter what kind of layout is is or what views are in it.. anything that seems to go through AppCompat hits this error in the preview. 似乎不管是什么类型的布局或者其中有什么视图......看似通过AppCompat的任何内容都会在预览中遇到此错误。

Have never seen this before. 以前从未见过这个。 Previously had Android Studio 2.3 Canary 2 + Support libs 25.0.1. 以前有Android Studio 2.3 Canary 2 +支持libs 25.0.1。

Seems like it's just not possible to ever upgrade Android Studio or its support libs without spending hours on this type of stuff, hey? 好像它只是不可能永远升级的Android Studio或它的支持库没有这种类型的东西花费数小时,哎?

Thanks for any hints, thanks- 感谢任何提示,谢谢 -

UPDATE UPDATE

Looks like I'm not the only one. 看起来我不是唯一一个。 Found a bug logged here, starred by many people already: 发现此处记录的错误,已被许多人主演:

https://code.google.com/p/android/issues/detail?id=230183 https://code.google.com/p/android/issues/detail?id=230183

UPDATE 2 更新2

Still an issue with AS 2.3 Beta 1. Still can't see my layouts. 仍然是AS 2.3 Beta的问题1.仍然无法看到我的布局。 Same java.lang.NoSuchFieldError: ViewBackgroundHelper error everywhere. 相同的java.lang.NoSuchFieldError: ViewBackgroundHelper错误无处不在。

According to the issue tracker, as of Jan 10, 2017: 根据问题跟踪器,截至2017年1月10日:

https://code.google.com/p/android/issues/detail?id=230183 https://code.google.com/p/android/issues/detail?id=230183

For those of you using the 2.3.0-beta1 Gradle plugin could you please disable the build cache by adding 对于那些使用2.3.0-beta1 Gradle插件的人,可以通过添加来禁用构建缓存

android.enableBuildCache=false

to your gradle.properties file and let us know if that fixes the issue for you. 到你的gradle.properties文件,让我们知道是否能解决问题。 After adding the line to your gradle.properties, please rebuild the project. 将行添加到gradle.properties后,请重新生成项目。

Thanks. 谢谢。

Has proven to solve the issue for some users. 已经证明可以为一些用户解决问题。

Everything works now. 现在一切都有效。

  1. I upgraded today to the newest Android Studio: 2.3 Beta 3 我今天升级到最新的Android Studio:2.3 Beta 3
  2. I was prompted to update to the latest com.android.tools.build:gradle:2.3.0-beta3 我被提示更新到最新的com.android.tools.build:gradle:2.3.0-beta3

Restarted, invalidated, rebuilt; 重启,失效,重建; everything is finally rendering perfectly in the preview pane for the first time in 6 weeks . 一切都在6周内第一次在预览窗格中完美呈现

Looks like they've fixed it. 看起来他们已经修好了。 Finally . 最后

I filed the issue on the tracker. 我在跟踪器上提交了这个问题。 Other participants have discovered that removing some other non-android library dependencies causes the issue to go away. 其他参与者发现删除一些其他非android库依赖项会导致问题消失。 Based on that I found a solution (reposted from the issue thread): 基于此我找到了一个解决方案(从问题线程转发):

Additional information after investigating this further: 进一步调查后的其他信息:

Android Studio 2.2.3 Android Studio 2.2.3
Build #AI-145.3537739, built on December 2, 2016 Build#AI-145.3537739,建于2016年12月2日
JRE: 1.8.0_76-release-b03 amd64 JRE:1.8.0_76-release-b03 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains sro JVM:JetBrains sro的OpenJDK 64位服务器VM

Support libs: 25.1.0 支持库:25.1.0
Build tools: 25.0.2 构建工具:25.0.2

After being able to reproduce this on the above studio version (2.2.3 Stable), I began removing other library dependencies based on the information provided by others in this thread. 能够在上面的工作室版本(2.2.3稳定版)上重现这一点后,我开始根据此线程中其他人提供的信息删除其他库依赖项。 After removing the Calligraphy library ( https://github.com/chrisjenx/Calligraphy ) and associated code, the layout preview began to work correctly again. 删除书法库( https://github.com/chrisjenx/Calligraphy )和相关代码后,布局预览再次开始正常工作。

Interestingly enough, I was able to re-add the Calligraphy library and the layout preview continued working. 有趣的是,我能够重新添加书法库,并且布局预览继续工作。 Maybe this points to some sort of caching problem with the android gradle plugin? 也许这指向android gradle插件的某种缓存问题?

For others encountering this problem, I suggest the following: 对于遇到此问题的其他人,我建议如下:
1. Pinpoint the library causing the problem 1.找出导致问题的库
2. Remove the library dependency and associated code 2.删除库依赖关系和相关代码
3. Do a full clean and build 3.做一个完整的清洁和建设
4. Verify the layout preview works 4.验证布局预览是否有效
5. Re-add the library dependency 5.重新添加库依赖项
6. Do a full clean and build 6.做一个完整的清洁和建设
7. Verify the layout preview works 7.验证布局预览是否有效

Note: I suspected Calligraphy was causing the problem because it relies on a custom xml attribute called "fontPath", as well as some Context manipulation. 注意:我怀疑书法引起了问题,因为它依赖于一个名为“fontPath”的自定义xml属性,以及一些上下文操作。 If you have any libraries that do View manipulation under the hood, I suggest removing those first. 如果你有任何库在幕后进行View操作,我建议先删除它们。

Change your AppTheme style to this: 将AppTheme样式更改为:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
</style>

I have a Solution the problem is not the version of Android Studio. 我有一个解决方案,问题不是Android Studio的版本。

The problem is the Gradle Version go back to stable version 2.2.3 it work for me after a few test. 问题是Gradle版本回到稳定版本2.2.3,经过几次测试后它对我有用。 It is a Bug in gradle beta version and it is already reported to google. 它是gradle测试版中的Bug,已经报告谷歌。

I resolved this problem in the next steps 我在接下来的步骤中解决了这个问题

  • Remove <project>/<module>/build/build/intermediates/exploded-aar 删除<project> / <module> / build / build / intermediates / explosion-aar
  • Rebuild project 重建项目
  • Check that there is only one version support-library in exploded-aar 检查在explosion-aar中只有一个版本支持库

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

相关问题 所有com.android.support库都必须使用完全相同的版本规范。 在android studio 2.3中找到版本27.0.2、25.1.0、25.0.0 - All com.android.support libraries must use the exact same version specification . Found versions 27.0.2, 25.1.0, 25.0.0 in android studio 2.3 25.1.0 Android支持lib正在打破fab行为 - 25.1.0 Android support lib is breaking fab behavior Android Studio Beta 2不显示XML布局预览 - Android Studio Beta 2 not showing XML layout preview 带有Android Studio 2.3的Android支持回购46.0.0 - Android Support Repo 46.0.0 with Android Studio 2.3 在OSX上进行调试时,Android Studio 2.2和2.3 beta 2冻结 - Android studio 2.2 and 2.3 beta 2 freeze when debugging on OSX Android studio 2.2预览5设计编辑/预览好像坏了吗? - Android studio 2.2 preview 5 design editor/preview seem to be broken? 如何通过curl下载android支持库25.1.0? - How to download android support library 25.1.0 via curl? Android - fragmentTransaction.replace()不适用于支持库25.1.0 - Android - fragmentTransaction.replace() not works on support library 25.1.0 无法解决:com.android.support:appcompat-v7:25.1.0 - Failed to resolve: com.android.support:appcompat-v7:25.1.0 无法在Android Studio Preview 3.2-beta 1中构建我的项目 - Could not build my project in Android Studio Preview 3.2-beta 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM