Do not build Android project automatically on opening - android

I have been using Android studio for a long time, yet never understood what are the processes that Android studio runs at when we load a new project via File>New or File>Open. We just load the project and have to wait for so many minutes before the android studio completes those processes (I know that we can still click on file names and editor would open them, but i have observed the android studio will still lag until all those processes are completed)
However I don't know how, recently My Android studio started behaving differently. I don't know what i did, But every time i created a new project, or loaded a previous one, it would show a message like this:
This was very good for me, because even when i don't click the try again
button, I am still able to access all files and without any lag, thereby removing a need for external file editor. I feel this was some bug in gradle or cache handling that got fixed when i uninstalled AS and updated to AS 3.5 .
So is there a way to manually run all those build and indexing processes, instead of Android Studio just running them automatically?
UPDATE:
I think i was not clear before. I want that error to occur . Meaning I want to have a control over when the building process starts. Also, I am NOT having any error as of now, all my projects are working fine.

Look for highlighted warnings in you Gradle file, you may need to update some things and then sync again.
You could also try to clean and rebuild your project.
You can also File->Invalidate Caches / Restart if none of the above work.
If none of the above work, please provide more details on what warnings/errors you get.

When version conflict in gradle file, it cant be able to build and sync the project.There may be show "Unsupported Modules Detected: Compilation is not supported for following modules”. Fix them too

Related

Code Suggestions stopped Working (Flutter)

After creating a new Flutter Project in VSCode/Android Studio, there are just no code suggestions. Pressing ctrl+space usually brought up suggestions in both, but now on Android Studio it says no suggestions, and on VSCode I get the usual few snippets, no IntelliSense.
Weird thing is when I tried reopening previous projects, some projects are still fine, some projects have the same issue. I have attached screenshots of when it works, and when it doesn't
PS: I'm not sure if this is related but in VSCode just when a new project is made it fails to recognise the header file so it highlights everything as Error though the code runs fine. However this gets fixed when the window is reloaded
This usually happens when your IDE is not sync with the version of Dart and/or Flutter used in the project ; that's why on some projects it still works, and not on the other.
Option 1 :
Try to update your Dart/Flutter version on the project, and on the plugin/extension of the IDE. Watch out to have the last version of your IDE, not on beta channel, as well.
Option 2 :
If still not working after the update, delete IDE related files in problematic projects and reopen them.
Last time worked for me, hope it will for you !

Android Studio gradle build stuck at app:processDebugResources

I'm on Windows. I created a new project on Android Studio for Marshmallow at least.
The only thing I've done so far is generating the main activity which is a tabbed activity with view pager. Also, you should know that this project is a private git repo that I cloned.
I'm working on this project with another developer and the project is perfectly working on his side.
The problem is:
When I try to launch the app (wether it is a virtual device or my real phone), the gradle build gets stuck at the app:processDebugResources step. I waited more than an hour and nothing happened. Moreover, when I want to cancel the gradle build, it doesn't respond and I have to kill Android Studio process. Then I restart Android Studio and I have to kill a gradle process that prevents the initial gradle build (at Android Studio startup) from working.
The crazy thing is that I was able to launch the app before. I even installed it on my phone!
What I've tried so far:
Do what stackoverflow was giving as solutions like tick the offline mode in the settings
Create a new project --> It doesn't change anything
Reinstall Android Studio --> It doesn't change anything
Deactivating Avast antivirus
Invalidate cache/restart + Clean + rebuild (the rebuild gets stuck like when I try to launch the app)
And maybe other solutions that I forgot...
It's getting very annoying as it's making me lose days of development.
If you have any more solutions, or if you think I should try again some of the previous solutions, help would be greatly appreciated !
I know this is an old post, but I faced the same problem during the last few days and since i got crazy I hope I can help someone else out there.
After many hours of troubleshooting I found that the Java Platform SE binary executable goes in "suspended mode" in Windows 10, preventing Android Studio from compiling (it hangs at app:processDebugResources).
Example Screenshot
Killing the suspended process and recompiling the project works just fine... until Java gets suspended again.
Maybe your gradle version is not compatible with it. Try again with latest version of gradle in your project.
I did several things:
Install NDK
Change JDK from embedded one to Jdk 8
Redownload SDK i was using (6,7,8)
And now the problem is solved ! I have no idea which of these things made the tricks but I'm happy ! It may be useful to someone else one day.

Android Studio: Code changes not reflected when pressing run app even with instant run off

Since a couple of days code changes are not reflected when I press run app (^r). I now have to run my app twice before the actual code change is applied.
Yes I could clean my project of course, but I wouldn't want to clean my project for every time I want to check code changes. Also Instant Run is disabled so it shouldn't have anything to do with that.
I am running on Android Studio 2.3.3
- kotlin 1.1.3
- gradle 2.3.3
- buildTools 26.0.0
Is there anything I can do here to get this issue fixed?
edit:
- changes are in kotlin files as well as in xml files, both need 2 app starts before app gets updated to latest code changes :s. Tried invalidate cache and restart but that isn't solving the problem...
I face the same problem when i change html files. Studio cannot recognize changes in html files and does not re-deploy application.Uninstall the application on device and then run app.It should work.

Gradle not syncing at all?

I just updated AS since a while and Gradle seems to be broken.
Create a empty LibGDX gradle project with the latest LibGDX setup.
Add dependency to core in build.gradle. Nothing happens, used to get a popup with something like "Sync now" I believe.
Clean project does not seem to do anything. Bottom left says nothing about a recent (un)successful clean.
Rebuild project does not seem to do anything.
Adding jibberish sdfdfsdfsffsd;;;sfes;efs to the gradle file does not change anything. My program still runs, no errors in build.gradle and clean still does not do anything.
Never really had problems with AS and Gradle, it just worked out of the box. Now it seems to be broken but I cannot seem to find anything on the subject. A reinstall might fix things but fixing it without a reinstall would be nice.
Edit
I somehow managed to trigger the gradle sync by closing/opening AS and opening my project again. But now it won't even recognize the LibGDX framework anymore.
Edit
Somehow it seems related with unchecking Android in the LibGDX setup tool. This was no problem in the past for me but once I tried to create a project with the android module enabled it seems to work. My guess is the LibGDX tool messes up somewhere with generating the gradle files but it's still very strange behavior. Perhaps someone could attempt to start a project without the android module and tell me if he is running into the same issues. Note that at first import the default LibGDX program runs fine but importing dependencies through Gradle and restarting AS is causing issues here.

Android Studio stuck while building application

I recently switched from Eclipse to Android Studio because I read that it is now the official IDE for Android application development. I downloaded and installed the latest version (1.0.2) for Windows. When using the program for the first time, I decided to create a test application to see if the program was working correctly. Unfortunately, it was not. Once I clicked the finish button to complete the New Project Wizard, A loading bar showed up that said Gradle: Build. This is where the program gets stuck. There is no error message and it appears that the program is running fine, however the build never actually completes. I am never given my MainActivity.Java class, or my activitymain.xml document. If I click the cancel button, the program freezes and I have to use the TaskManager to kill the program. If I re-enter the program and choose to open an existing project, my project will be there. However, upon trying to open the project, I am greeted with the same Gradle: Build loading bar.. I have been searching for an answer for the last 3 days and nothing has worked. Any help is greatly appreciated!
Things I have tried:
Simply letting the program sit for a while to see if it was actually downloading something and was just really slow. I let it sit for 45+ minutes before killing the program.
Uninstalling and re-installing Android Studio
Restarting my computer
Turning off my firewall (Kaspersky)
Running the program as an administrator
Connecting to a different network
Disconnecting my computer from any networks (to force the program to build in offline mode)
Manually downloading Gradle from the link that Android Studio attempts to use when it gets stuck and telling the program to use that file instead of downloading another one.
(I went to this link https://services.gradle.org/distributions/gradle-2.2.1-all.zip, downloaded the file, unzipped it, went to Gradle settings in Android Studio, checked the Offline work checkbox, and finally set the service directory path to my unzipped Gradle folder.)
Hopefully I have given enough information and made it clear what my problem is. If not please tell me what else I need to explain so I can get this issue resolved. Thanks!
Please note I am working on a 64 bit machine running Windows 8. Also, I use studio64.exe
to run the program.
From the discussion we had in the comments, it does not look like you have your gradle on your windows path.
Please change the below to point to your gradle install:
set GRADLE_HOME=C:\<installation location>\gradle-1.11
set PATH=%PATH%;%GRADLE_HOME%\bin
After this, verify that in the terminal running the following works:
gradle tasks
once you get this working, you will want to run the following in your project:
gradle wrapper
This will produce a .bat file which you can then use to run gradle through the wrapper, letting you support multiple native gradle installations.

Categories

Resources