Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio 3.1 XML preview not showing for some XML layouts

Some layouts are shown, some just have blank, gray frame. I can't seem to find a correlation between XML layouts that work and those that do not, there is a mixture of use of binding, constraint layout, varied in complexity and length, error-free. The app is compiling and running well.

Any suggestions?

Clearing cache/restarting, cleaning, rebuilding had no effect on this

Solution: Noticed a red error icon next to layout in preview mode. It had something to do with id resources resolver @1 . I manually edited one of resource ids on a layout. This somehow fixed issue with rest of the layouts. Weird.

Edit: It seems that problem keeps reoccurring. Changing theme on the preview does however help. I would also try to change preview mode to blueprint if you are having problems.

Edit 2: I've went with Android Studio 3.2 Canary 9 and layouts are working as expected without problems. I'm guessing it had something to do with new-old bindings compiler

Edit 3: Oh god... problems are not ending. 3.2 Canary 11 uses up all given memory fast while editing layouts and then GC keeps lagging all IDE for me. Need to restart IDE every 30mins. I end up reverting to 3.1.1 and if things are not loading I force refresh layout as it was suggested in below comment.

like image 777
P.C. Blazkowicz Avatar asked Mar 28 '18 12:03

P.C. Blazkowicz


2 Answers

For me, only "Force Refresh Layout" worked. Restarting, re-building, cleaning didn't work.

enter image description here

like image 101
Rohan Taneja Avatar answered Sep 23 '22 00:09

Rohan Taneja


i solved it by changing the below dependency

from

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

to

implementation 'com.android.support:appcompat-v7:27.1.1'
like image 44
Muhammad Awais Rashid Avatar answered Sep 22 '22 00:09

Muhammad Awais Rashid