问题
I have a problem. When I start a new project in Android Studio and select a navigation drawer activity it happens. I don't have access to my activiy_main_drawer.xml
on "Design" and it keeps saying "Waiting for build to finish.". I really don't know what I have to do. I tried to uninstall and reinstall Android Studio, and it didn't help.
回答1:
I've just run into the exact same problem. I simply solved it by choosing Sync Project with Gradle Files
. This will trigger a Gradle re-import and a build.
As of Android Studio v3.2, the icon is located near the top right tool bar. You can also find it using Find Action
shortcut CtrlShiftA.
回答2:
File -> Sync project with Gradle files
回答3:
You can do the following:
"File > Sync Project with Gradle files" (worked for me)
File > Invalidate Cache & Restart > Just Restart
OR
File > Invalidate Cache & Restart > Invalidate & Restart
Close Project and Re-Import the Project
回答4:
Have the save problem, the Android SDK was missing from my system. After installation of this missing SDK, its running fine.
回答5:
What worked for me was, from the top menu:
Build -> Clean
Build -> Rebuild Project
After that the xml design worked
回答6:
I am using Android Studio 3.1.3 (#AI-173.4819257), Android Build Plugin for Gradle 3.1.3 and Gradle 4.4. I tried all possible options mentioned on various posts but nothing worked for me. I want to use ConstraintLayout which is default with AS 3.1.3. My observation and workaround are as follows.
Observation: This issue occurs when a new project created with empty activity and default layout. I also get "IDE Error Occurred" once Gradle sync finishes.
Workaround: Create an empty activity, activity class (MainActivity.java
) and layout (activity_main.xml
). Once it is done, create a new layout file (say activity_cltest.xml
) using New -> Android Resource File after clicking right button on "app". Create new layout as per your requirements. Once done, update MainActivity.java
by replacing R.layout.activity_main
with R.layout.activity_cltest
.
I also tried to copy content of activity_cltest.xml
to activity_main.xml
but still for activity_main.xml
, error persists. Effectively, once a new project is created, activity_main.xml
should not be used and deleted.
However, for some reasons, syntax highlighting of "R.layout.activity_cltest" within MainActivity.java
doesn't work.
回答7:
Just create a new XML file using the same name and copy paste activiy_main_drawer.xml file codes. It works for me.
回答8:
I uninstalled my 3.1.2 and installed version 3.2 Canary 18 from Android Studio download archives. Everything is fine now.
We welcome all constructive edits, but please make them substantial. Avoid trivial edits unless absolutely necessary.
回答9:
Ah... I resolved it with the help on this page and a little bit more effort.
I installed Android Studio v.3.3.1 today on my Zenbook. I was stuck with the same error "waiting for a build to finish" and Display tab was not showing up for activity_main.xml Here is what I did to resolve this error.
Step 1. I searched for SDK tools and downloaded required SDK versions.
Step 2. downloaded Gradle 5.2.1 and extracted the files in Program Files\Android\Android Studio\gradle
Step 3. File>Settings>Build..>Gradle and choose the local distribution of Gradle 5.2.1
Step 4. Go to File>Sync Project with Gradle files and allow some time to sync...
finish() :) developing android with Kotlin
回答10:
My experience: I was accidentally importing "myself" into the view, creating infinite loop:
item_task.xml
<androidx.recyclerview.widget.RecyclerView
...
tools:itemCount="3"
tools:listitem="@layout/item_task" /> <---- circular dependency mistake
Setting a correct list item in the recycler view solved the issue.
回答11:
Syncing gradle, reopening, rebuilding, invalidating caches and restarting, trying different Android studio versions. None of these helped. When I would open XML preview I would still see that damn issue.
What helped in the end is closing Android studio, going to gradle directory:
cd ~/.gradle/
And deleting caches folder:
rm -rf caches
After that reopening Android studio will take some time as it still has some rebuilding to do, but afterwards all xml layouts were being properly rendered again.
来源:https://stackoverflow.com/questions/49737865/android-studio-waiting-for-build-to-finish