简体   繁体   English

Android Studio 渲染问题

[英]Android Studio rendering problems

I'm using Android Studio 0.2.3 and when opened an activity layout normally, the preview should appear on the right side, so that I can switch between Text and Design mode, which should again show the preview of the layout.我使用的是Android Studio 0.2.3 ,当正常打开活动布局时,预览应该出现在右侧,以便我可以在文本设计模式之间切换,这应该再次显示布局的预览。

But no preview is shown not on the right side neither when I'm in text mode nor in the design mode.但是无论是在文本模式还是在设计模式下,都不会在右侧显示预览。 I just get the error rendering problems...我只是遇到了错误rendering problems...

When I compile everything and install the app on my device, it works without any errors.当我编译所有内容并将应用程序安装在我的设备上时,它可以正常工作而没有任何错误。 For developing and experimenting with the layout, it would still be nice if I could get the preview to work.对于布局的开发和试验,如果我能让预览工作,那还是很好的。

I have also tried to switch between different devices in the studio, but no success.我也尝试过在工作室的不同设备之间切换,但没有成功。

Does anyone know how solve this?有谁知道如何解决这个问题?

Change your android version on your designer preview into your current version depend on your Manifest.根据您的清单,将设计器预览中的 android 版本更改为当前版本。 rendering problem caused your designer preview used higher API level than your current android API level.渲染问题导致您的设计器预览使用了比您当前的 android API 级别更高的 API 级别。

根据您当前的 API 级别进行调整

Adjust with your current API Level.根据您当前的 API 级别进行调整。 If the API level isn't in the list, you'll need to install it via the SDK Manager.如果 API 级别不在列表中,则需要通过 SDK 管理器安装它。

In new update android studio 2.2 facing rendering issue then follow this steps.在面临渲染问题的新更新android studio 2.2 中,请按照以下步骤操作。

I fixed it - in styles.xml file I changed我修复了它 - 在我更改的 style.xml 文件中

"Theme.AppCompat.Light.DarkActionBar"

to

"Base.Theme.AppCompat.Light.DarkActionBar"

It's some kind of hack I came across a long time ago to solve similar rendering problems in previous Android Studio versions.这是我很久以前遇到的某种 hack,用于解决以前 Android Studio 版本中的类似渲染问题。

  1. Open AndroidManifest.xml打开 AndroidManifest.xml
  2. Change:改变:

     android:theme="@style/AppTheme" android:theme="@style/AppTheme"

    to something like:类似于:

     android:theme="@style/Theme.AppCompat.Light" android:theme="@style/Theme.AppCompat.Light"
  3. Hit "refresh" button in the "Previev" tab.在“预览”选项卡中点击“刷新”按钮。

I was able to fix this in Android Studio 0.2.0 by changing API from API 18: Android 4.3 to API 17: Android 4.2.2通过将 API 从API 18: Android 4.3更改为API 17: Android 4.2.2,我能够在 Android Studio 0.2.0 中解决此问题

This is under the Android icon menu in the top right of the design window.这是在设计窗口右上角的 Android 图标菜单下。

This was a solution from http://www.hankcs.com/program/mobiledev/idea-this-version-of-the-rendering-library-is-more-recent-than-your-version-of-intellij-idea-please-update-intellij-idea.html .This required a Google translation into English since it was in another language.这是来自http://www.hankcs.com/program/mobiledev/idea-this-version-of-the-rendering-library-is-more-recent-than-your-version-of-intellij-idea的解决方案-please-update-intellij-idea.html 。这需要谷歌翻译成英语,因为它是另一种语言。

Hope it helps.希望能帮助到你。

In the Latest Android Studio 3.1.3 , Dependency:在最新的 Android Studio 3.1.3 中,依赖:

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'

or要么

Even in latest by 27th of Aug 18 ie即使最晚在 8 月 18 日 27 日,即

implementation 'com.android.support:appcompat-v7:28.0.0-rc01' facing similar issue implementation 'com.android.support:appcompat-v7:28.0.0-rc01'面临类似问题

Change it to将其更改为

    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1

This will solve your problem of Preview.这将解决您的预览问题。

UPDATE更新

Still, in beta01 there is a preview problem for latest appcompact v7 library make the above change as changing it to alpha01 for solving rendering problem尽管如此,在beta01 ,最新的appcompact v7 library在预览问题,将上述更改更改为alpha01以解决渲染问题

I have solved the Problem by changing style.xml我已经通过更改style.xml解决了这个问题

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
     <!-- Customize your theme here. -->
</style>

this was an awesom solution.这是一个很棒的解决方案。

当我在 .xml 文件中设置android:autofillHints="" />时,我遇到了问题, Android Studio 渲染问题,所以我设置了android:autofillHints="testHint" /> ,这个问题就消失了。

it still happens in Android Studio 1.5.1.它仍然发生在 Android Studio 1.5.1 中。 on Ubuntu and you can solve it simply changing a setting from Gradle:在 Ubuntu 上,您只需从 Gradle 更改设置即可解决它:

1) on app/build.gradle dependencies change from: 1) 在app/build.gradle 上的依赖项从:

compile 'com.android.support:design:23.2.0'

to:到:

compile 'com.android.support:design:23.1.0'

2) rebuild project 2)重建项目

3) refresh view 3) 刷新视图

Best regards,最好的问候,

/Angel /天使

I had the same problem, current update, but rendering failed because I need to update.我有同样的问题,当前更新,但渲染失败,因为我需要更新。

Try changing the update version you are on.尝试更改您使用的更新版本。 The default is Stable, but there are 3 more options, Canary being the newest and potentially least stable.默认是稳定的,但还有 3 个选项,金丝雀是最新的,可能是最不稳定的。 I chose to check for updates from the Dev Channel, which is a little more stable than Canary build.我选择从 Dev Channel 检查更新,它比 Canary build 更稳定一些。 It fixed the problem and seems to work fine.它解决了问题,似乎工作正常。

To change the version, Check for Updates, then click the Updates link on the popup that says you already have the latest version.要更改版本,请检查更新,然后单击显示您已经拥有最新版本的弹出窗口中的更新链接。

In build.gradle below dependencies add:在 build.gradle 下面的依赖项中添加:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == "com.android.support") {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "27.+"
            }
        }
    }
}

This worked for me, I found it on stack, addressed as the "Theme Error solution": Theme Error - how to fix?这对我有用,我在堆栈中找到它,称为“主题错误解决方案”: 主题错误 - 如何修复?

Rendering didn't work for me too.渲染对我也不起作用。 I had <null> value on the right side of the android icon.我在 android 图标的右侧有<null>值。 I ran我跑了

sudo apt-get install gradle

I restarted Android studio then and <null> value changed to 23 .然后我重新启动了 Android studio, <null>值更改为23

Voila, it renders now!瞧,它现在呈现! :) :)

在此处输入图片说明

Just download minimum prefered SDK from SDK Manager, then build.只需从 SDK Manager 下载最小首选 SDK,然后构建。 Works for me.为我工作。

Make sure your designer version and targetSdkVersion both is same.确保您的设计器版本和 targetSdkVersion 都相同。 Example : If your targetSdkVersion is 22 then change your designer version also 22, so this problem do not occur.示例:如果您的 targetSdkVersion 为 22,则将您的设计器版本也更改为 22,因此不会发生此问题。

Best Solution is go to File -> Sync Project With Gradle Files最佳解决方案是转到 File -> Sync Project With Gradle Files

I hope this helped我希望这有帮助

All you had to do is go to styles.xml file and replace your parent theme from您所要做的就是转到styles.xml 文件并从中替换您的父主题

 Theme.AppCompat.Light.DarkActionBar 
to 
 Base.Theme.AppCompat.Light.DarkActionBar

Open your activity_main.xml .打开您的 activity_main.xml 。 Switch to Design view if you are in text view.如果您在文本视图中,请切换到设计视图。 Look for the android version,with the android robo icon.寻找带有 android robo 图标的 android 版本。 Change the android version.换安卓版本。 Problem solved.问题解决了。

this issue is probably derived from the connection of the laptop to software products like AnyConnect.此问题可能源于笔记本电脑与 AnyConnect 等软件产品的连接。 Killing the remote connection works for me.终止远程连接对我有用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM