The Android Studio layout cannot preview the solution, and the pro-test is effective

background:

In AndroidStudio, it often happens that a layout is created or an existing layout cannot be previewed, and design or split has no effect

Some say it's because of the theme. In fact, part of it is because of the theme. Add a Base in front of the original theme parent to become Base.Theme.Light, etc. But most are unsolvable.

But it cannot be solved when initializing or loading appears. The best way is to delete

Project configuration information and gradle configuration files. Because if idea and gradle are abnormal, the layout cannot be previewed.

To delete these two files, we need to restart the dev tools

Reopen, the history cache and settings of the entire project are gone. It becomes a clean project again, so that when the initialization is completed, the damaged file has been replaced with a new one, and the layout can be loaded normally

Delete->file-> restart  , as long as it appears, follow this step

Remarks: If your layout can be displayed through this method, but if you open another project, the new project cannot be displayed, which will cause other projects to be unable to be previewed. At this time, you can still follow the above steps. Some projects have customization issues that prevent some layouts from being previewed, and the resulting cache files cause other project previews to fail as well.

The second type:

If the above deletion still fails, it may be caused by your IDE JAVA environment. Since your local JDK is running and the JDK that comes with the IDE is also running, there will also be an exception when JAVA is loading, resulting in the layout not being displayed. The layout is refreshed in real time .

Open the task manager, find the AndroidStudio task, and kill all Java processes under the current AndroidStudio task.

 

Guess you like

Origin blog.csdn.net/qq36246172/article/details/122639386