[android-studio] How can I fix "Design editor is unavailable until a successful build" error?

there are different solutions to this problem but I at the first u have to check to (build.gradle) maybe it empty. this especially if u downloaded code, not u created
and u will find just this line "// Top-level build file where you can add configuration options common to all sub-projects/modules." in this case, u need to open a new project and make copy-paste.then check the SDK and other settings.finally u have to sync