Android Studio waiting for build to finish

前端 未结 17 964
我在风中等你
我在风中等你 2020-12-12 15:26

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

相关标签:
17条回答
  • 2020-12-12 15:27

    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.

    0 讨论(0)
  • 2020-12-12 15:30

    In my case it was because I specified recycler view's tools:listItem="<item_layout>" in body of <item_layout> (nested recyclerviews). Just removing this tools option solved it.

    0 讨论(0)
  • 2020-12-12 15:32

    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

    0 讨论(0)
  • 2020-12-12 15:32

    Have the save problem, the Android SDK was missing from my system. After installation of this missing SDK, its running fine.

    0 讨论(0)
  • 2020-12-12 15:32

    Sometimes while converting the code from java to kotlin some library may get imported like import android.R Just remove this library.

    Check this tools:context=".MainActivity" in xml while copying another XML the class name will also get copy.

    Else try File -> Sync project with gradle or rebuild the project.

    0 讨论(0)
  • 2020-12-12 15:33

    Just create a new XML file using the same name and copy paste activiy_main_drawer.xml file codes. It works for me.

    0 讨论(0)
提交回复
热议问题