Missing project.gradle in Android View

筅森魡賤 提交于 2019-11-29 02:55:25

问题


In Android Studio, project.gradle file is not show when in Android View, but is when in Project view

Android View

Project View

How can I fix this ??


回答1:


From the Gradle Tool Window in Android Studio (View > Tool Window > Gradle),

  1. Right click on the the project's Gradle config with (root) next to its name.
  2. Click on Ignore Gradle project,
  3. and right click again then click on Unignore Gradle project.



回答2:


The trigger to this 'buggy' phenomenon actually lies outside your project folder.

Assuming a project name of 'SilverBirch', try this:
(a) Close the project in Android Studio 3.0.1.
(b) Rename your project folder (inside the workspace folder) to 'SilverBitch'
(c) Re-open it via Android Studio (you obviously can't do so using 'recent projects')
(d) You should get a window titled Import Gradle Projects with text that reads: The modules below are not imported from Gradle anymore. Check those to be removed from the ide project too:
(e) Tick the (old) project name and click OK.
(f) At last your 'Android' view shows build.gradle(Project:SilverBitch)
(g) Repeat whole process, renaming back to original.

Alternatively, if you're insane, do this:
Locate the project.dat file AND folder for your project - it will have a path that looks something like this (assuming Windows)

C:\Users\<userid>\.AndroidStudio3.0\system\gradle\Projects\5be1ee38\project.dat

[The system-generated hex-string container name will vary, but the file is always project.dat]
The first line of this file references the 'missing' build.gradle and will clearly identify the owning project.
Delete the file AND its containing folder then re-open the project via Android Studio.

Because googling 'project.dat' yielded nothing, and because I made a rude assumption that this contained only system-generated data, and because I couldn't resist 'seeing what happens' I actually deleted the entire Projects file [C:\Users\<userid>\.AndroidStudio3.0\system\gradle\Projects] So far, so good - no serious side-effects yet! Maybe those plugins needed re-specifying anyway? etc.




回答3:


Close Android Studio -> Remove project .idea folder -> Open Android Studio -> Open your project. This worked for me!

NOTE: when you remove .idea folder you will also lose project related preferences (such as XML code style for project)




回答4:


  1. Right Click on "Gradle Scripts"
  2. Click Load/Unload modules
  3. Load unloaded project module
  4. Done



回答5:


This worked for me:

In your root project folder, open the *.iml file, and make sure that the value in module external.linked.project.id=, the *.iml filename, and the project directory name are all the same.

Now my build.gradle (Project: X) shows.




回答6:


In my case, I found that my project.iml located in project/.idea So I move it to project/ and change one line like following:

<module fileurl="file://$PROJECT_DIR$/My_Project.iml" filepath="$PROJECT_DIR$/My_Project.iml" />

the old one should look like this:

<module fileurl="file://$PROJECT_DIR$/.idea/My_Project.iml" filepath="$PROJECT_DIR$/.idea/My_Project.iml" />

After that, go back to android studio, every thing seems perfect!




回答7:


This worked for me.

  • Simply go to your AndroidStudioProjects Directory.
  • Search for your Project
  • Rename it with some other name
  • Strat your Android Studio, and then Import Project (Gradle, Eclipse ADT, etc.) mode. let the Gradle Build Finish.

And that's it.



来源:https://stackoverflow.com/questions/46230078/missing-project-gradle-in-android-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!