Why Project's build.gradle is not showing? - android

Why is Project's build.gradle not showing up in Android mode?
Just like the picture below, the .gradle file in the project root directory can also be displayed in Android mode.
enter image description here

You need to change it at here. You choose to display the project instead the Android.

You changed the display mode. Notice that the first image, you configured to "Project Mode" and the second one is in "Android Mode". It's on the upper-left corner of the "project" tree view.

Your using project structure better to use android structure view
secound thing is if you want to use project structure then project->build.gradle is your project level gradle file for Ex. AndroidWeather/build.gradle

This can happen when the caches get messed up. Try this:
Close the project in Android Studio
Delete the .idea folder in the project folder:
In Android Studio, File / New / Import Project... and select the folder of the project
Note, to delete the folder:
cd /path/to/project
rm -rf .idea
Now you should see the project-level build.gradle in the Android scope.

Related

why is the "app" folder missing from my android studio 3.5.3

I'm new to the android studio. I made a new project, with these options:
1- language= java
2- for phone or tablets
3- empty activity / no activity
but the folders in my project are completely different from everyone else.
.
why is this happening to my project? why I don't have Java, manifest, build.gradle (module:app) and ... folders in my project?
In project section may you left side android icon and
right side setting icon
do:-
click on setting icon ,hence you can see Compact middle package, select this.
your gradle is not build successfully.
rebuild project. see gradle problem, and fix it for solve project structure.
Happened to me recently. Files existed. Only visible under the Project...Project tab.
I prefer the Project... Android... tab
It was only showing the "Gradle Scripts" and missing the "app" folder.
App Missing in Android Tab of Android Studio
In Android Studio "Welcome" dialog, remove project from recent list
Close everything Explorer Navigate to folder
C:\Users\Andy\AndroidStudioProjects[project]\
Search *.iml
Delete these files (backup beforehand as always)
Open Android Studio as Administrator
Open Project with “Open” button and browse to file folder
Android tab… “app” should appear now.

Rename root module in android studio

How to rename root module in android studio? I have tried (right click the module then click refactor then click rename) but I got warning "can't rename root module"
I pressed Ctrl+Shift+F to search my current root module name and found the name to be in the settings.gradle file as rootProject.name=.... I renamed it and synced the project (File -> Sync Project with Gradle Files) and the root module name was updated.
In root of your project
open setting.gradle and change
rootProject.name='YOUR NEW NAME'
then close and restart android studio
Close the project. (File > Close)
Rename the root folder of the project.
At the welcome screen "Open an existing Android Studio project" and provide the new path.
On your link that's the second answer or see also here.
This is tested for a pure Java projects (without any C/C++ code):
close the project and make a copy of the folder containing it
rename the new copied folder to reflect new project name
delete all *.iml files
reopen the project: Android Studio will resync Gradle, rebuild iml files
review the modules.xml file to remove reference to old project name
new project renamed works exactly as previous one: you can run the app without completely reinstalling it (all previous app data/settings/cache will be preserved)
Video tutorial: https://youtu.be/7aQjiae2doU
Refactor the name to com.example.[NewFileName] in path:
app>java>com.example.[OldFileName]
Go to strings.xml and change code to <string name="app_name”>[NewFileName]</string> in path:
app>res>values>strings.xml
Go to build.gradle (Module: app) and change code to applicationId "com.example.[NewFileName]” in path:
Gradle Scripts>build.gradle (Module: app)
Go to settings.gradle (Project Settings) and change code to rootProject.name='[NewFileName]' in path:
Gradle Scripts>build.gradle (Project Settings)
Press Sync now prompt
Rename your folder to [NewFileName] outside Android Studio
Reopen your project and rebuild project in path:
Build>Rebuild Project
In your Project pane, click on the little gear icon ( setting icon at the right top)
Uncheck / De-select the Compact Empty Middle Packages option
Your package directory will now be broken up in individual directories
Individually select each directory you want to rename, and:
Right-click it
Select Refactor
Click on Rename
In the Pop-up dialog, click on Rename Package instead of Rename Directory
Enter the new name and hit Refactor
Allow a minute to let Android Studio update all changes
Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All

Android studio, how to delete folder with references?

i would like to delete one folder (unused library) from my project in Android Studio. But i cannot to do that by delete key on keyboard or any other way.
I tried to found delete under refactor->safe delete, but this option is disabled.
If i removed folder manually from folder, Android studio created a folder again and putted in one .iml file, so i cannot delete folder again.
Thanks for any help.
Remove it from settings.gradle
Build --> Clean (the blue rectangle should disappear)
Right click on module -->Delete
To remove a module, you first have to delete it from .idea/modules.xml.
Once you do that and save the file, you'll be able to delete the folder, which will no longer be marked with the module's blue rectangle.
Don't forget to remove the module from settings.gradle.
I found this aswer at delete project in android Studio 0.3.4
The problem is occurring because of workspace.xml and modules.xml inside .idea directory of your project.
You cant not delete any module if there is blue rectangle over it, Follow the steps to delete your module from project :
Go to File> Project Structure , select the module you want to delete and press the red minus sign button to remove.
Note : Also remove if any reference in build.gradle file of your main module.
Clean your project using Build > Clean Project
Close your Android Studio now
Go to the project directory and delete the your_project.iml file and content of .idea folder from project root directory, also delete the module directory which you want to remove.
Open Android Studio again and let it sync the project with gradle
If module appears again there will not be any blue rectangle mark on it so you can delete by right click > delete and clean your project.
Sync your project again with gradle, if it appears again check your event log if somewhere something from library is used, if it is remove them all.Check your File > Project Structure as well if there are any error referring to your module library on bottom. If it is using the red bulb button remove it.
After remove all things Clean Your project and sync again.
Let me know in comments if any problem occurs.

Android Studio "Project Structure" not coming properly

I follow all the necessary steps for Android Studio installation. I also checked this question, but still facing the same issue.
But whenever I create any new project, following screen come. I couldn't found any project structure as I can see in Eclipse.
Here, I can't find any "src","res" or any file structure. Any idea, how to get proper Project Structure?
when I tried to add "New Module" following error comes to submit.
No message
java.lang.IllegalStateException:
at com.android.tools.idea.wizard.NewModuleWizard.onFailure(NewModuleWizard.java:159)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:340)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$1.run(ExternalSystemUtil.java:364)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:493)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:304)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
at com.intellij.openapi.application.impl.ApplicationImpl$10$1.run(ApplicationImpl.java:695)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:458)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:154)
When I go to Edit Configuration, can't create any module due to above error.
Go to File > Project Structure > Project Settings > Modules.
Click on the green colored + and add new module.
select Application module and set the content root to your project module.
Click next and then finish.
This should do the trick and the complete project structure will appear.
It worked for me.
Change the SDK to a level that you have installed in the SDK manager. The SDK manager can be accessed from Tools -> Android -> SDK Manager. For me, Android Studio was packaged with API Level 17 but the new project wizard tried to target API Level 18.
When something like that happens to me, to fix it, I go to
File -> Project Structure -> Modules, click (+) to add a module.
To import the main module you have to search for the IML extension file to load the project structure configuration again (for example app.iml), and thats all. I hope it helps.
Kip2's solution worked for me with a slight variation:
1.) File -> Invalidate Cached/Restart..
once android studio restarts:
2.) File -> Sync Project with Gradle Files
Just doing "File -> Sync Project with Gradle Files" (or doing "File -> Sync with File System"), did not correct the problem. I had to invalid the cache first, and then sync the project with gradle files for the project to display properly.
Finally find solution.
Whenever Android Studio starts, it search for "Gradle" installation. If not found, it will download new version of it and cache it here.
C:\Documents and Settings\user\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok
Here 72srdo3a5eb3bic159kar72vok directory name may be different.
What you need to do is, download gradle-1.6-bin.zip, place it in above directory. Then decompress it there. But make sure your path should like below.
C:\Documents and Settings\crathod.SOLUSOFTINDIA\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\gradle-1.6\bin
Now, when you restart your Android Studio, Gradle will be initialized and Project will opened in Full Project Structure.
Modules or the project structure could also not appear because you're in a branch where *.iml files are missing. This happened for me when I was migrating from Eclipse and had decided to check back into the original branch that had the Eclipse-like project structure. What solved my problem:
Checkout the branch with Android Studio-like project structure
File -> Invalidate Cache & Restart
Also, make sure that the root iml file matches case with your root folder. Incorrectly named iml file will cause such problems.
Just delete the root iml file (you can backup if you like), close the project and re-open it. Android Studio will generate the correct iml file and the project structure will be restored.
This is tested on Android Studio 2.1
Before:
  
After:
  
  I got the java folder (src folder) and others.
Solution:
  
File > Sync Project with Gradle Files
Android Studio Version: 3.2.1
Note: This case did not appear on the old version. For example, 1.5.1 (2016/03 before)
Keywords:
file explorer
file structure
file hierarchy
file system
folder & file list
project explorer
project structure
project hierarchy
disappear / gone / did not see
Android Studio bug / issue
simple way to restore
Delete the project hidden .idea file and .gradle file and restart your project this will fix your issue.
I deleted the app from the list of apps when you open Android Studio, then I reimported the project.
For Android Studio 2.2, you can simply click the left bottom and then select Project
In Android Studio 2.3.1, you don't have the Application module option if you wanted to add a module. The best solution is to right click your project and select "Jump to the source" from the menu. That solved my issue.

How to fully remove an external library in a project?

I would like to fully remove all the links to an external library in my project. How can I do that ?
What I did:
Right click on project folder => Properties => Android => remove the library in the right panek
Right click on project folder =>Build Paths => Configure build paths =>In the right panel: the folder relative to the library can be expanded; I manage to remove one of the resources in this expanded fodler but not the others (and consequently not the root folder)
The library (.jar) is still visible in my project above the assets folder and I don't manage to remove it. Below how it looks (cannot be remove by right click and delete (gray)):
Any help would be appreciated !
Maybe You have to go:
right click on your project:
properties > select "Android"
Under "Library", remove the library you want.
It maybe some libraries include other libraries so you couldn't remove it from where you have tried.
Right click on the jar file -> Build Path -> Remove from Build Path
Open settings.gradle and delete:
"include ':librayname'"
Then delete lib file from app Myproject/app folder.
I was able to remove an External Library after following these steps:
Remove compile entry from build.gradle (app)
RESTART Android Studio.
Following steps worked for me :
Right click on JAR file in libs folder
Choose option Refractor and then select Safe Delete Option
Delete this entry from build.gradle --> compile files('libs/)
open Android Studio terminal and execute this command --> gradlew clean
jar file will be deleted but Code you have used from the jar file will still be there in java files. you can manually delete that.

Categories

Resources