Android Studio (Dolphin | 2021.3.1) & (Electric Eel | 2022.1.1) does not show layout preview
Asked Answered
M

32

101

I'm using Android Studio Dolphin | 2021.3.1 & Electric Eel | 2022.1.1

After updating Android studio chipmunk | 2021.2.1 to Android studio Dolphin | 2021.3.1 my all project design preview and layout preview not showing. If anyone solved this issue please help me.

I have tried all possible ways but didn't find any solution for this. Below are points that I have tried

  1. Invalidate caches.
  2. Restart IDE.
  3. Repair IDE.
  4. Update Gradle plugin version to 7.3.0 from setting project structure (No working)

Check the Below screenshot so everyone gets an idea of what I have issue faced.

enter image description here

Thanks in advance.

For me, some layouts are working fine but in some layouts, I am getting the below error which used to work in earlier versions of Android Studio.

enter image description here

The same issue I faced in Android (Electric Eel | 2022.1.1). Still, this Issue continues.

Maiduguri answered 19/9, 2022 at 11:17 Comment(26)
There appear to be a variety of bugs with Dolphin's layout preview. If you create a new empty project, does preview work there?Trisa
Yes, I have created a new project and the preview is working fine.Maiduguri
A couple of the bugs that were reported are related to themes that have missing elements. Are any issues reported with your themes? If you switch from "Split" to "Design" and switch the preview theme, do you get better results?Trisa
No, I tried every possibility but get the same result. @TrisaMaiduguri
I resorted to reinstalling the chipmunk versionLepido
I have same issue. Preview has render problem and it says: "/app/src/main/res/font/montserrat_bold.xml does not exist (or is not a file)". But the file is exist.Submergible
@Submergible exactly the same issue I have also facing.Maiduguri
I am also facing the same issueWhipstall
You can add to your style: <item name="android:textColorHighlight">@color/colorEditTextLight</item> <item name="android:textColorLink">@color/colorPrimary</item>. I hope it will help you.Pennon
Try to use style instead of android:.Pennon
same issue i'm facing after update studio. any way to solve it ? i'm getting Failed to find '@attr/font_10' in current theme.Chickweed
@Chickweed check this answerContorted
@AndroidDev Already applied this solution but didn't work.Maiduguri
Whats excat issue ? Got any error at runtime?Contorted
@AndroidDev check this question I have already attached a screenshot and description.Maiduguri
Yes there is attr problems but we can still show ui by changing theme in xml preview untill patch for this camne I don't think it;s coming in near time because same issue in Elcetic el canery.Contorted
@AndroidDev if you using attr android:theme="?attr/yourStyle" then not working layout preview in android dolphin you need to downgrade your android studio version link of android version developer.android.com/studio/archiveApproximation
@KaushalPanchal have you found any fix?Fatuous
@TehleelMir Not yet. We have to wait until Google fixes this issue or we have to downgrade the studio to chipmunk.Maiduguri
I'm testing AS Eel, and it's working, so you could use Beta or wait until Eel becomes available on stable channel.Fantasize
@Fantasize thank you for your suggestion but I want to use a stable channel so, I'm waiting for Eel Stable channel.Maiduguri
@KaushalPanchal I have updated Android Studio to Eel and still facing same issue.Lakieshalakin
@voidpointer my suggestion is to wait for some days. I think this issue is still not resolved in Eel stable version. bcoz I have faced some issues in Eel.Maiduguri
For me it was an old Lottie version. I upgraded Lottie and XMLs started to show up.Mcvay
@KaushalPanchal any solution or still facing same issue ?Chickweed
@Chickweed still facing the same issue.Maiduguri
I
47

I was able to fix this by changing the preview's theme from App.Starting [default] to my app's theme from the Design Tab

enter image description here

Instalment answered 20/9, 2022 at 14:18 Comment(3)
can you share more detail? because I try this but didn't work. Thank you for your answer.Maiduguri
worked for me. thanks @KaushalPanchal set your app main theme in dropdownCommissar
Worked for me using Android EelEncephalomyelitis
R
11

After alot of searching and testing, I upgraded my gradle version and its work for me.

Just goto File -> Project Structure or press Ctrl + Alt + Shift + S and then upgrate the gradle version as shown in the image below and then invalidate cache and restart the Android Studio and its working

enter image description here

As shown in the image I upgrade my gradle.

Rodl answered 20/9, 2022 at 7:25 Comment(8)
Let me check and update here soon.Maiduguri
even after gradle plug-in update it's not working. Getting below error. infinite cycle trying to resolve '?textAppearance': Render may not be accurate.Nutritionist
what is the problem you are facing?Rodl
@SyedRafaqatHussain I have edited the original question with the error screenshot which i am facing.Nutritionist
@SyedRafaqatHussain Thank you for answering, but in my case after gradle plug-in update it's not working.Maiduguri
@KaushalPanchal check this answer may be it's help to solve remaining error after updateContorted
@AndroidDev Already applied this solution but didn't work.Maiduguri
You may try : File -> Sync project with gradle filesZecchino
P
9

Apparently, there are many people reporting the exact same issue to Google but no concrete solution has been given so far:

I tried most of the suggestions from the other answers, but the only thing that has worked for me so far was upgrading to Flamingo (2022.2.1 Canary 10) or downgrading to Chipmunk (2021.2.1 Patch 2).

These solutions are obviously far from ideal, but until Google decides to fix this in either Dolphin or Electric Eel, I believe that's what we're stuck with.

Polydipsia answered 23/12, 2022 at 19:30 Comment(1)
Yes @Renan Ferrari. We have to wait until Google fix this issue or we have to downgrade the studio to chipmunkMaiduguri
C
7

In my case, I found two situations.

1. Include

the android studio can't show the XML if it contains the "include" tag.

My project has more than 100+ XML files that have the include, and none of them can show the preview. Otherwise, it was fine.

Setting the app theme doesn't work for this case.

Edit: Custom font can be a problem
Still I am not sure, but loading font can be a problem. I set isEditMode() condition to all Typeface, and it looks like the preview rendering issue was solved.



2. Setting app theme

On top of the preview screen, you can select the app theme. (If you can't find it, try enlarging the android window itself. Then the hidden app theme menu will be revealed.)

Then, try setting some theme, such as "AppTheme" or "BaseTheme", etc. Then, for some cases, this will show you the preview.

Chyou answered 21/9, 2022 at 12:57 Comment(1)
The same issue I am also facing in my projects I have more than 30 projects, and Only the layout preview is not showing rest of everything is working fine. Thanks for yor answer.Maiduguri
C
5

Frankly guys tried everything as suggested in mentioned answers, but doesn't seems to work for me, might be a recent Android Studio bug.

Sharing something what worked for me (workaround, not a fix)

I accidentally clicked the LayoutValidation tab as mentioned in screenshot, and for now using it to preview my design while updating XML code. Preview gets updated as you make changes.

But yes this might not be helpful if want to make changes using design.

enter image description here

Chromato answered 28/1, 2023 at 14:25 Comment(1)
Only this solution worked for me, Thanks. Android studio version - Android Studio Electric Eel | 2022.1.1 Patch 1Lakieshalakin
B
4

Use material:1.8.0-alpha01 dependency. alpha02 has issue showing preview.

Barony answered 6/11, 2022 at 9:32 Comment(3)
Thank you from answer but i have used stable version of material library also i have more then 100 project so i can't manually change dependency versionMaiduguri
Same here, updating material to the latest version solved my own issue (render problem / invalid character *)Tunstall
This did work for me thanks! Actually trying other versions like 1.9.0-beta01 did not work as well.Swick
D
3

I tried to update gradle but not work with me.

so after that i changed them from

Theme.MaterialComponents.DayNight.NoActionBar

to

Theme.Material3.DayNight.NoActionBar

work with me

if this solution does not work with you

add this line to root group view in layout

android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar.Bridge"

another solution

down material version to this version

material_version = '1.6.1'

I hope that helps you.

Daunt answered 4/10, 2022 at 12:35 Comment(0)
S
3

To solve temporary this issue. Change theme for preview using "AppTheme". This is work for me. For detail see the attachment file image

enter image description here

enter image description here

Socialite answered 31/10, 2022 at 11:55 Comment(1)
I am not sure if the OP had the same problem or not, But this did the job for me.Jaynajayne
E
3

here is how i got it to show up i clicked on this icon in the preview and i also changed the theme to appTheme

enter image description here

Electromagnet answered 16/3, 2023 at 8:19 Comment(2)
Thank you for answering but still does not work for me.Maiduguri
Changing to app theme made the trick, thanksRashad
S
2

New solution:

I just tried the latest canary build of Android Studio Flamingo and it seems that the layout preview is now fixed! At least it works for me again without any problems, with MDC 1.8.0-alpha03 and the latest gradle plugin and gradle version.

Old solution:

It appears to be a bug in Dolphin in connection with API 33, but for me at least the layout preview toolbar is shown. In case the preview toolbar is somehow accessible, the following workaround solves the disappeared preview (at least for me): Select API 32 in the layout toolbar instead of the preselected API 33.

Then the preview is shown to me as it should and I do not have to downgrade anything and can use the latest gradle version.

Sack answered 20/9, 2022 at 23:56 Comment(1)
I try this but didn't work.Dagan
O
2

I have same issue as above just solved by doing below things

Setting - SDK tools and check for Android Emulator Update just Update it and Rebuild project and Done

No need to downgrade API versions.

enter image description here

Note - if not work after it just try to invalidate cach and restart

Option 2

after doing above task try to just update or select app theme from above preview design enter image description here

Octillion answered 22/9, 2022 at 13:51 Comment(4)
Thanks for the answer, I have already used latest android emulatorMaiduguri
actually after this my preview shows but for only 2-3 sec after that it disappear again so i tried by selecting theme as in my updated answer and it worked well.Octillion
Ok, let me try this.Maiduguri
This did not work. Even with all the cache restarts and so on. Its either not showing or not correctly showing or just for 2 seconds. installed and reinstalled all sdk tools, emulators and so onTheodore
D
2

Don't use alpha version. Use this

implementation 'com.google.android.material:material:1.7.0'

If you wanna use alpha version, make sure using Android Studio preview version.

Derr answered 24/1, 2023 at 1:48 Comment(0)
B
1

Starting with Android Studio Chipmunk, if you're seeing java.lang.NoSuchFieldError: view_tree_saved_state_registry_owner or java.lang.ClassNotFoundException: androidx.savedstate.R$id in the issues panel, make sure to include a debugImplementation dependency to androidx.lifecycle:lifecycle-viewmodel-savedstate in your module.

If you're seeing java.lang.NoSuchFieldError: view_tree_lifecycle_owner in the issues panel, make sure to include a debugImplementation dependency to androidx.lifecycle:lifecycle-runtime in your module.

If you're seeing java.lang.NoClassDefFoundError: Could not initialize class androidx.customview.poolingcontainer.PoolingContainer or java.lang.NoClassDefFoundError: androidx/customview/poolingcontainer/PoolingContainerListener in the issues panel, make sure to include a debugImplementation dependency to androidx.customview:customview-poolingcontainer in your module.

Issue tracker : https://issuetracker.google.com/issues/247058594

Workaround Solution : File - Project Structure -

enter image description here

Battiste answered 21/9, 2022 at 11:27 Comment(1)
This is still not resolved. My all-old project layout editor not showing the preview in Android Studio Dolphin | 2021.3.1Maiduguri
H
1

Change the AGP Version and Increase Gradle version if you have not in Project structure > Project to latest version the click apply and wait for gradle to complete. After completing, Just Invalidate Cache and restart. It worked for me.

enter image description here

Holton answered 21/9, 2022 at 21:56 Comment(0)
A
1

I have also encountered this issue. Switching Android Gradle Plugin to 7.3.0 for all projects and 7.4 for gradle solve this problem.

Anthiathia answered 24/9, 2022 at 2:35 Comment(0)
A
1

Try to remove/modify any drawable resource files that you are using as style/background in your layout. It may cause Render problem/Touch size/Touch Target too small. In my case I was using such resource files, after modifying those, the layout is visible to me. Thanks.

Alberthaalberti answered 13/10, 2022 at 11:11 Comment(1)
Thanks for your answer. But in my case this manual modification is not possible.Maiduguri
G
1

I had the same issue and solved it by ignoring some errors in the issue panel

enter image description here

Not this specific issue, this is for example sake

Gleet answered 15/11, 2022 at 16:9 Comment(0)
M
1

I'm on Android Studio Electric Eel and I managed to fix the issue after a whole day of trying by replacing com.google.android.material:material version 1.8.0 with 1.7.0. Even though 1.8.0 is now 'stable' it was the one causing the issue.

Miceli answered 13/2, 2023 at 16:35 Comment(0)
C
0

In my case solve this issue I do following steps

First I just update Gradle plugin version to 7.3.0 from setting project structure (No working)

after that I also update com.google.gms:google-services version to 4.3.14

now every things work fine.

Cambyses answered 29/9, 2022 at 9:19 Comment(0)
D
0

I was using custom views, styles and fonts from a library and ran into this when upgrading to Dolphin. I fixed the issue by upgrading the libraries compile SDK to 33. Upgraded gradle to 7.3 and upgraded androidx.appcompat:appcompat to 1.4+

Once you do that, invalidate caches and rebuild and it should work.

Google is aware of this issue https://issuetracker.google.com/issues?q=dolphin%20layout%20preview

Downgrading to Chipmunk until a patch is released will also fix the issue if you can't or wont upgrade.

Drumlin answered 29/9, 2022 at 16:54 Comment(0)
L
0

Try to upgrade your gradle version to latest (whatever it may be). Mine Worked

Linnlinnaeus answered 21/10, 2022 at 4:47 Comment(0)
G
0

If all these solutions are not working then you can try below option as well. Disable lottieAnimation in the xml file, and reBuild the app, then it is working fine now.

Gravel answered 7/11, 2022 at 10:14 Comment(0)
H
0

For you that because of others dependencies cannot update the Android Gradle Plugin:

You'll have to wait a little bit, the devs are already aware. There should eventually be a version to correct this.

For now what you can do to keep working is downgrading the Android Studio Version to Chipmunk | 2021.2.1 (or older)

Huerta answered 7/11, 2022 at 17:6 Comment(0)
S
0

Maybe it's not going to fix your problem. But it may helps someone who gets into the same trouble as I had. I have an extended layout, the exception says it's not able to initial this class, and pointing to a singleton property variable.

private SingletonProperty property = SingletonProperty.getInstance();

Turns out it's not possible to have a singleton field in a layout class(which it's okay before Android Studio Dolphin). Everything works fine after I move it into several methods. Don't forget to build your project after this.

Sylph answered 10/11, 2022 at 13:44 Comment(0)
P
0

For me, disabling assertions fixed the issue.
I found the fix here: https://issuetracker.google.com/issues/255525863
To disable assertions, add -da to Custom VM Options:

enter image description here


In case that Android Studio won't start after applying the new options,
the custom VM options file is located at:

macOS:

~/Library/Application Support/Google/AndroidStudio2021.3/studio.vmoptions
Punchy answered 18/11, 2022 at 17:5 Comment(0)
F
0

I had the same problem if you are using custom views in your layout, checkout this answer https://mcmap.net/q/212521/-android-studio-layout-editor-cannot-render-custom-views.

Fatuous answered 26/12, 2022 at 9:55 Comment(0)
L
0

enter image description here

Open Layout Validation tab from right side or search it from toolbar search menu now see the issue in my case is inside MaterialAutoCompleteTextView after investigating issue is android:fontFamily="More Fonts..." font is not point to right one enter image description here

Littles answered 20/1, 2023 at 23:59 Comment(0)
U
0

I also had the problem of the layout page not appearing and it was not solved in any way until I made a copy of it and deleted the entire layout one by one to find out which view had the problem. It is interesting that the copy of the layout was intact and worked exactly.

Ursel answered 27/1, 2023 at 22:46 Comment(0)
S
0

It seems like the root problem is our system's lack of memory and all solutions just refresh the procedure of rendering the layout. You just have to run it on a system with more RAM.

Skiascope answered 2/3, 2023 at 23:28 Comment(2)
In my system 16gb RAM, still i'm facing same issue.Maiduguri
Exactly. Mine is 16, too. This happens through periodic updates of Android Studio: it requires more RAM after a specific release. Similar issues happened years ago when 8GB RAM was considered to be sufficient and after some time and releases, Android Studio couldn't work with that amount of RAM; specifically the emulator would automatically stop working and became closed.Skiascope
M
0

Upgrade Android Studio Electric Eel 2022.1.1 Patch 2 to Flamingo | 2022.2.1 RC 1 helps me to solve this issue for now. I have tried many other answers and finally this one worked for me. Later need to update to stable version of Android studio.

Millymilman answered 29/3, 2023 at 3:7 Comment(1)
OK, Let me try this.Maiduguri
C
0

I had the same issue using the latest version. I fixed it by removing the line:

android.enableAppCompileTimeRClass=true

I've also seen people report removing android.nonTransitiveRClass=true line. But I didn't need to do this.

Cowherd answered 28/6, 2023 at 6:6 Comment(0)
P
-3

Downgrade to Android Studio Chipmunk (2021.2.1) Patch 2 https://developer.android.com/studio/archive

It will work after that.

Pedanticism answered 20/9, 2022 at 7:25 Comment(3)
Thanks for your answer but I want to use the latest android studio, not the old one. This solution I already apply.Maiduguri
Downgrading the android studio could be one of the solution, but the main focus here is the Dolphin.Chyou
Upgrade to Android Studio Flamingo | 2022.2.1. fix the problemPeople

© 2022 - 2024 — McMap. All rights reserved.