Android-Studio refresh project with build.gradle changes - android

how can I sync changes I made in the build.gradle into the project structure ( e.g. that AndroidStudio is recognizing the lib I added?
Kind of like the "reimport all maven projects" for maven projects - just for a pure gradle project.

I read somewhere that the "Synchronize" item on the module's context menu should update the IDE's settings based on the build.gradle file.
Ok, so in the latest version of Android Studio 0.1.3, they've added a Gradle project refresh button next to the other Android specific buttons in the toolbar. Make changes manually to the build.gradle files and settings.gradle and then click this button. It should configure and refresh your project settings based on the gradle files.

One thing that has worked for me was opening the Gradle panel on the right side of the editor (above "Maven Projects" and "Commander") and clicking the refresh button. That refreshed the module settings.

For Android Studio 4.1.2 click on the button pointed on picture

My solution for newer version of Android Studio. Tested on version 3.2.1. You can selected Refresh from the menu as showing here:

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.

Android Studio Gradle Icon Grey-Bullish [duplicate]

This button disappeared from a new 3.1 version of AS Toolbar. Before it showed as:
Now it's missing:
EDIT: They like to keep playing with the toolbar.
Since Android Studio 3.3, the icon has been updated and moved back across to the right:
Original answer:
It hasn't disappeared. They have just moved it between the Save and Sync files button on the far left end of the toolbar.
In Android Studio 3.3 it is here:
Is is available from menu. Tools > Android disappeared, so find it in File > Sync Project with Gradle Files.
For me I did following to make it visible:
Go to File -> settings -> Menus and Tool bar as shown
Click on Restore Default
You should see the Updated Android.MainToolBarGradleGroup as follows:
Click on Apply and restart the Android Studio
If you encounter this issue within a Flutter project and you cannot find the sync method, you can click on the build.gradle file and then click on Open for Editing with Android Studio at the top right. This will open just the Android project in a new Android Studio window and you will be able to see all the Gradle commands then (for example, under File > Sync...).
File > Sync Project With Gradle Files or this shortcut.
If you are creating React Native application, make sure that you opened your project in ~/YourProjectName/android folder
You can use this shortcut Ctrl + Shift + A to get not only sync but also other action if you found trouble to get them.A window will appear and you can type some command that you would like IntelliJ to run. Just type "sync" in there and it will find that command Sync Project with Gradle Files, even if it's not visible on the menu.
I had to open /android/ on its own in Android Studio (you can click Open for Editing in Android Studio in the top right corner) and then you have this options in the toolbar and in File/Synch Project with Gradle Files (when viewing .gradle file).
In Android Studio under 3.1 it's placed in
Tools > Android > Sync Project with Gradle Files

Where is a "Sync project with gradle files" button in Android Studio 3?

This button disappeared from a new 3.1 version of AS Toolbar. Before it showed as:
Now it's missing:
EDIT: They like to keep playing with the toolbar.
Since Android Studio 3.3, the icon has been updated and moved back across to the right:
Original answer:
It hasn't disappeared. They have just moved it between the Save and Sync files button on the far left end of the toolbar.
In Android Studio 3.3 it is here:
Is is available from menu. Tools > Android disappeared, so find it in File > Sync Project with Gradle Files.
For me I did following to make it visible:
Go to File -> settings -> Menus and Tool bar as shown
Click on Restore Default
You should see the Updated Android.MainToolBarGradleGroup as follows:
Click on Apply and restart the Android Studio
If you encounter this issue within a Flutter project and you cannot find the sync method, you can click on the build.gradle file and then click on Open for Editing with Android Studio at the top right. This will open just the Android project in a new Android Studio window and you will be able to see all the Gradle commands then (for example, under File > Sync...).
File > Sync Project With Gradle Files or this shortcut.
If you are creating React Native application, make sure that you opened your project in ~/YourProjectName/android folder
You can use this shortcut Ctrl + Shift + A to get not only sync but also other action if you found trouble to get them.A window will appear and you can type some command that you would like IntelliJ to run. Just type "sync" in there and it will find that command Sync Project with Gradle Files, even if it's not visible on the menu.
I had to open /android/ on its own in Android Studio (you can click Open for Editing in Android Studio in the top right corner) and then you have this options in the toolbar and in File/Synch Project with Gradle Files (when viewing .gradle file).
In Android Studio under 3.1 it's placed in
Tools > Android > Sync Project with Gradle Files

Module not specified after opening project from another computer

I keep my projects in my Dropbox folder. I installed Android Studio on my laptop and I tried to open the Project. All java files had a red circle which I managed to fix by marking the Directory as Sources Root. When I try to run the application, the Edit configuration window pops up with a sign at the bottom saying that Module is not specified, in red. There is no module I can select in the appropriate combobox. Syncing project with grandle files has no effect and importing the project instead of opening it makes things even worse. At the Projects side tab, by selecting the Android option, I can only see the Grandle Scripts structure and not the project files. The project files are visible when I select the Project option from the combobox.
The project cannot even open at the original computer anymore. I am new to Android and I have spent a lot of time developing this project. What can I do to reverse the situation?
You have to change some gradle properties.
First you open android studio and create a new project. Then change your old project's all gradle properties according to new project. like bellow--
Go to your build.gradle(Module:app) script and change the gradle version like compile 'com.android.support:appcompat-v7:25.3.1' to your current version.
Go to your build.gradle(Project:your app) script change this line classpath 'com.android.tools.build:gradle:2.3.0' to your current version.
Finally you have to change gradle-wrapper.properties(Gradle Version) distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
to your current version
Now sync your project, I hope it will working fine.

Android Studio Marks syntax as error, but gradle compiles

I have a project in Android Studio which compiles with Gradle.
The general file structure is
MyProject
- MyProjectSource
- Libraries
- ActionBarSherlock
My project is built with Gradle and will compile without issue. However in the lines within my activity where I include a component from ActionBarSherlock, Android Studio marks it as an error.
I have noticed that Android Studio has also generated .iml files. So my question: Does Android Studio ignore the gradle build when assessing whether something is valid syntax or not?
Obviously this is not a project blocking problem but it does slow velocity not being able to take advantage of the full set of tools Android Studio has to offer.
Thanks in advance for any help.
These are not errors actually, this a bug in Android studio( 0.4.2 ) for resolving the symbol and fixed for the next release( 0.4.3 ).
To get Rid of these until the release do the following
Clean your project using Build > Clean Project
Close your Android Studio
Take Backup of your project
Delete all .iml files inside your project
Delete content of .idea directory
Open Studio and wait until it completes the sync with gradle
Also verify if you are seeing any error in File > Project Structure . If there is any error saying "Dependency Not Added "click on that and using red bulb on right side Add them to dependency.
UPDATE
Android Studio 0.4.3 is available on Canary Channel Now.
UPDATE: #laochiv, I have found that cleaning manually the folder .idea/libraries and clicking afterward on "Sync Project with Gradle Files" solves the problem. Apparently this Sync does not remove elements, but keep the old ones and add the current ones. Probably a bug to report :)
I am having the same problem. However, I am using ABS directly from Maven.
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
}
Even the ABS Gradle Sample application marks a syntax error, although it compiles.
However, in another computer everything is working perfectly. I can not think of different conditions in each scenario.
"Does Android Studio ignore the gradle build when assessing whether something is valid syntax or not?" Yes. Android Studio imports the project configuration but runs its own compiler as you are editing and saving (you can even change it to the Eclipse ECJ compiler). The true authority on the build is Gradle, and AS is still in beta. You can try to run the gradle resync or close and reimport the project. I have had to manipulate AS like this many times, especially after making edits to build.gradle.
Edit: I have found it better to use ActionBarSherlock as a gradle dependency rather than a library directory.
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
You will need to use the SDK manager and install the local maven repository.
But it is possible to eventually get rid of these compile errors, as long as your build.gradle doesn't create any extra sourceSets that AS doesn't understand; try not to deviate too much from the android gradle plugin examples.
Also, I've been running the Canary updates of AS for the latest and greatest.
I don't know how to add a library using MavenCentral. I follow these steps to include a library
Add library in App_Name/App_Name/libs folder.
In App_Name/build.gradle add this
dependencies {
compile ---
compile files('libs/fileName.jar') }
./gradlew clean
Make sure your Android studio is updated.
Go through the link and it worked for me.
1.) Choose File option from menu on left top side of android studio.
2.) Select the option : "Invalidate Cache/ Restart.." It will open an dialog.
3.) Click on the first button with option : "Invalidate and Restart"
4.) It will close the studio and restart it. Start indexing of the project.
It resolved my problem
Go to File -> Invalidate Cache/ Restart -> Invalidate and Restart
Source
https://www.youtube.com/watch?v=FX_gCTpqhwM
I had this problem in Android Studio 4.2, it might be fixed on 4.3
I have noticed that adding some dependencies did not attach the classes.jar to the dependency, so Gradle recognises everything but the IDE doesn't. To fix it:
Open Module Settings of your project
Select the dependency that has the error
Click Add (+) for that dependency (bottom of the pop up)
Navigate to your-project/build/exploded-bundles/your-dependency/classes.jar
The IDE should recognise the files now
Hope it helps
I had this today and gradle update/sync didn't solve. But updating to latest version of Android Studio 2.2 update 5 fixed (was on 2.1).
Here i'm talking about android studio version v3.1.2 where this same issue happened.In later android studio version(above 3.0.1) this issue again rises. So, I solved this by going through few things and here is how
Close android studio first
Navigate to your Project Folder
Delete .gradle and .idea folder (.gradle and .idea is hidden files. so make sure you tick Show Hidden Files in your File Explorer option to see these files
Open your project in android studio now
This Time another issue (unsupported module) will arise, but don't worry. I got you
Goto File in android studio and hit Sync Project with Gradle Files
Tada..! you're done now!
Simplest Solution
Comment/Remove the dependency which is showing syntax error & Sync Project.
Uncomment/Add again & Sync Project.
Yeah! error gone...
Before
After

Categories

Resources