I tried fixing this for ages now, but I don't know what to do. How do I get it to display a preview? Here is a screenshot of the code:
-
Click on clean project and rebuild project. After you can see preview design. :) – Jigar Patel Nov 07 '17 at 18:52
8 Answers
Solved :
Try 1 : Just close and open the Android Studio
Try 2 : Build -> Clean project -> rebuild
Try 3 : Build -> Clean project -> rebuild -> restart Android studio
Mi

- 968
- 10
- 21
From Menu Open file option and choose option Close Project.
then restart your project android.
this will resolve your issue.

- 1,469
- 18
- 14
in my case, clean and build didn't work, I just close the project and open it again, it's solved

- 161
- 4
- 6
The attached screenshot shows your Project is not sync properly. Here are some of the possible steps:
- Use
Sync Project with Gradle Files
for more Here is answer with more detail. - If you made huge changes to project or changed package names etc. use
rebuild
In menu Build => Rebuild Project. - Preview may not show if an API is selected that is not properly installed. Check Answer here.
One of the above should fix the problem. If none of the above work try restarting IDE (Android Studio
).

- 6,548
- 8
- 42
- 69
Follow these steps-
- If you have any incomplete statement(s) in your code (probably where you left it last time) then comment those lines to make them inactive.
- Go to Build=>Rebuild to rebuild the project.
- Uncomment those lines to make them active again and you are done!!

- 2,236
- 3
- 26
- 48
Close the android studio and reopen the project again. If not work replace all 'compile' with 'implementation' from build.gradle file. Because it is obsolete now and will be removed at the end of 2018. I solved this kind of problem like that.

- 693
- 6
- 15
I tried above answers. But, sometimes they work and sometimes not.
I tried -
File -> Invalidate Caches/ Restart -> Invalidate and restart
And it always works for me.

- 2,016
- 2
- 19
- 30
I do this to solved the problem:
type
Ctrl
+Shift
+A
to open the "Actions" search windowinput "Sync Project with Gradle Files" , then type
Enter
wait for Sync finished

- 934
- 10
- 9