18

When I open layout file in my new Android-Studio file and press preview tab it'll show a message Waiting for build to finish... for infinite time. enter image description here

Has anyone faced the same issue or any solution?

Kuls
  • 2,047
  • 21
  • 39
Vikrant Shah
  • 547
  • 1
  • 4
  • 18

8 Answers8

10

Cleaning and rebuilding my project solved the issue.

Sumit Saurabh
  • 1,366
  • 1
  • 19
  • 33
6

try different theme (may be from Appcompat) and API level from top

OR

  1. If you have made some changes in the layout just undo it.
  2. delete .idea and .gradle folder from root of the project
  3. close android studio , restart it
  4. click on gradle icon from right sidebar and click sync icon to refresh project. now rebuild the project and it should work.
44kksharma
  • 2,740
  • 27
  • 32
  • 1
    removing the .idea and .gradle file worked for me. I was having this issue only in a project while other projects were working fine. – Hitesh Bisht Nov 28 '18 at 05:31
3

After a lot searching and I tried all solution which people give here, but any of them didn't solve my problem, I guess this problem is from studio's developers, and they may fix it in next patch. so I simply re-installed my android studio and it's solved.

Vikrant Shah
  • 547
  • 1
  • 4
  • 18
2

Try Clean and rebuild project.and Also try Invalidate caches/Restart.And this issue is also facing because of Low Ram in laptops.

Abhign01
  • 311
  • 4
  • 4
1

After upgrading to Android Studio version 3.1, in the Project Structure dialog the build tools version was empty. Selecting a build tools version solved the problem for me.

Hope it helps for someone facing the same issue.

Domenico
  • 1,331
  • 18
  • 22
0

See my response on similar question posted:

Android studio error java.lang.IllegalArgumentException: Resource name cannot be empty

This error can occur when you update to Android Studio 3.0. It doesn't affect your ability to build a project, but the error does not allow you to visually see your xml layout files. You will also get the error when committing files to GIT, but you can still commit and push.

What I found in one of my projects is that a file was added to the "menu" folder automatically upon Android Studio upgrade, and the file had no name. It was named simply ".xml". All you need to do is delete the file and clean your project, allowing a new build of the project. That should take care of the issue.

indyman777
  • 66
  • 2
0

For me I had this problem with one file, so I simply created a new one with the same code.

Aymen
  • 841
  • 1
  • 12
  • 21
0

Simply make a build from within AS - not the command line. I get this all the time because I'm mostly using the command line. It's been like this since early versions of AS so I recon it's not high on there list of issues. Lately (3.2) there is a lot of new internal crashes and what not - not stable at all

slott
  • 3,266
  • 1
  • 35
  • 30