android studio is taking too long time to build - android

I'm new to android and android studio is taking too long to build
and I'mscreenshoot not sure why

I have noticed that sometimes Android Studio builds either get stuck or slow down for seemingly no reason. First thing to try would be to quit Android Studio, then run ./gradlew --stop from the command line to make sure any Gradle deamons have been shut down completely. You may also want to do a ./gradlew clean to get rid of any intermediate files that might be troubling the build.
If that doesn't help, you may need to look into optimizing your build. There are lots of resources on the web, but you might want to start with the Android team's list of ideas.

Related

See logs when AndroidStudio is stuck on Gradle: Build

How to understand what and why really happens behind Gradle: Build? There is no console or crashes, just endless building. Maybe there is network issue which happens again and again, but how can developer know it?
This is a sample of just new project:
From terminal everything works fine. So the question is not about how to solve particular problem, but more about generic solution when IDE doesn't show anything except "progress".
You can execute ./gradlew build manually in the terminal to see its logs. You can also add --debug or --stacktraceparameter to enable verbose logging.
I have a similar answer to Andre, but with a suggestion of some potential culprits.
If an issue is happening, Android Studio is just a GUI wrapper on the terminal. So just run the commands and see what the hold up or error is.
However, Often times when I see freezing up that takes a long time to fail it is network related items. Such as an internal Maven repo that is not resolving properly. So check your internal Maven repos as well that they exist and you set them up correctly.
You can also turn off the internet and start it up, it will load into offline mode and not attempt to load any internet items and offers popup to move to offline mode in gradle. This will give you a chance to make your corrections until Android Studio improves these issues.
Rather than Choosing Start a New Android Project, Open an Existing Project and then
goto file>>new >>new Project
If You create android project by following these steps , You can see every error of you gradle build in
logcat

Android Studio Build Gradle Runnig too long without end

I have a project which was working very well on android studio , suddenly it turns not able to build anyway .. It keeps telling Build Gradle Runnig without any result for 30 min !
I tried to clear .gradle file of project without result.
I tried to uninstall android studio and clean all its files from user directory AndroidStudio 2.1 and .gradle files and also no result.
This problem occures only with this project and others working fine on android studio ..
What should I do to make my project build again ?!
I had that once when I updated the gradle wrapper. It really took 45 minutes to download that 16MB or so. I had to that time some network issues with their repo servers.
Try to run in the console gradlew aR and see what happens. If you see there hundreds of dots you need to wait if there happens nothing kill all java processes and try again.

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.

Gradle - high CPU use

I recently started to use Android Studio and while I like it a lot, there is one thing that annoys me a lot:
Gradle - it's nice tool and all, but damn it's such a resource hog, also it's just so painfully slow. No matter if I use my 5 years old laptop or my gaming PC, when it's running, other applications go to a full stop (well almost)...
Is there really a reason for a build tool to be so demanding??? I understand compilation can be a slow process but from my experience javac always seemed to be blazingly fast, so it cannot be source of a problem (also building Android apps with ADT was many times faster too)...
So is there something wrong with my configuration? Can I make Gradle run faster?
Create a gradle.properties file either in your project root directory or your ~/.gradle directory with the following line:
org.gradle.daemon=true
From the Gradle manual:
The Daemon is a long-lived process, so not only are we able to avoid the cost of JVM startup for every build, but we are able to cache information about project structure, files, tasks, and more in memory
Also, you can go to File > Power Save Mode if you want to turn off continuous building in Android Studio.

android studio build error debug-unaligned.apk path not found

Last night I updated my android studio to 0.5.3 and since than i am getting this error message whenever I am trying to generate a signed-apk. It does not occur when I am just running the project over android studio.
I tried rebuilding, cleaning project, restarting android-studio, reimporting the project, no success. I am pretty desperate right now
EDIT: i found out that actually debug-unaligned is not generated... But why is that? And why do i need to generate it if i am just trying to sign the app
In 0.5.3, we tried to speed up the build process by not having it do a full build to an APK except when it needs to, but we missed some cases where it needs to.
You can follow progress in https://code.google.com/p/android/issues/detail?id=67948 but in the meantime you can work around it by running the assembleRelease task, either from the command line or from the Gradle tasks view:

Categories

Resources