Android Studio takes too much time to execute an app - android

I am using Android Studio 2.0.0 beta 3 version and whenever i run an app it takes around 1m 30s to run minimum. I have experienced even upto 3m 50s delay for executing an app which is really frustrating. Below are few things that i have tried to fix this,
In app's gradle file,
dexOptions {
preDexLibraries=false
incremental=true
javaMaxHeapSize "8g"
}
In User/.gradle/gradle.properties
org.gradle.daemon=true
org.gradle.parallel=true
Im using below version of tool, in build.gradle file outside app's module
classpath 'com.android.tools.build:gradle:2.0.0-beta3'
I have also enabled Offline Mode in Settings -> Gradle section. Please share your thoughts.
Edit:
System Details:
Intel I7
16gb RAM
Windows 8.1 Os 64-bit
I also have 3 product flavors and 4 build types in the project.
I even sometimes think android studio is much worse than eclipse. I have read gradle provides lot of great features. Does the gradle cost us this execution time to make those pros? or Is it just because of IntelliJ? Can someone who knows about this better explain.. which will help a lot of devs like me.

Related

Low speed when the output in Android Studio

When click on run application to phone or emulator in Android Studio, i should wait 15 min or up !
I have't this problem before and running application in phone / emulator on 1 min! but now when running application in phone / emulator i should wait 15 min or up to build Gradle !!!
How can i fix this problem and faster to build Gradle ?
I encountered the same issue.Try these steps to make faster builds upto 3x faster:
Make sure you don't have unnecessary gradle dependencies
In the settings go to compiler-check combine independent modules parallel
In the settings go to gradle and then click on offline mode.(This will cause your gradle to not to use internet while building project,dont use this if you are adding any new dependency)
Thanks,hope it'll help.

Taking a lot of time to build gradle

I'm doing a project in my office in Android Studio, it was working fine there.
But when I open the same project in my personal laptop in Android Studio it's taking a lot of time to build gradle.
Please, does anyone have a solution?
I have also face same problem, actually your personal laptop not compatible to run android studio, in the documentation of android they mentioned that 4 GB RAM is sufficient but my personal experience said that RAM should be 8 GB, its also depend on your operating system in MAC os android studios running smoothly then in Linux its also give good performance but in Windows its creating a problem, i think you need to upgrade your RAM.
Add this line to the file:
org.gradle.daemon=true
From now on Gradle will use a daemon to build, whether you are using Gradle from command line or building in Android Studio. You could also place the gradle.properties file to the root directory of your project and commit it to your SCM system. But you would have to do this, for every project (if you want to use the daemon in every project).
Note: If you don’t build anything with Gradle for some time (currently 3 hours), it will stop the daemon, so that you will experience a long start-up time at the next build.
Note: Performance improvements are one of the great tasks in the Gradle roadmap for 2014 (and reaching into 2015). So I hope, we’ll see the general performance increasing within these years.
Note: This does only affect console builds. Android Studio always uses a Gradle daemon (and depending on your settings some other optimizations).
Found the reason!! If Android Studio has a proxy server setting and can't reach the server then it takes a long time to build, probably its trying to reach the proxy server and waiting for a timeout. When I removed the proxy server setting its working fine.
On Windows File > Settings > Appearance & Behavior > System settings > HTTP Proxy

Extremely slow gradle build

The following measures were taken to speed up gradle build from this (SO post)
org.gradle.parallel=true, org.gradle.daemon=true
build from terminal and not from android Studio
building with ./gradlew assembleDebug --offline
Problem:
Even after these measures build times can take upto 6-8 minutes for a single line of code change! and during this time computer mostly freezes and nothing else can be done except to stare at the terminal. I've noticed that "app:dexDebug" takes a lot of time in this. What are the possible causes?
Relevant files:
Terminal build dump
build.gradle(app)
build.gradle(project)
System details:
Android Studio 1.2.2
Description: Ubuntu 14.04.2 LTS
You can try disabling your lint checks by adding this code to your build.gradle
tasks.whenTaskAdded { task ->
if (task.name.toLowerCase().contains("lint")) {
task.enabled = false
}
}
Also you can use the --profile parameter to export a html report of what's taking so long in your build time
EDIT: removed the debug check
We had a similar problem: our build took about 4 minutes. After some research, we get next steps:
Try turning on offline work in your Gradle settings (Ctrl + Alt + S for the Settings, then Build Tools -> Gradle settings). Usually, we do not update libraries so often and Gradle will not check that they are up to date.
Multidex increases the time for build: Android documentation. To mitigate this, you can add additional flavors for debug and production builds, setting for debug builds minSdk = 21 (suggestion from official site).
If you have several modules in project, try to flatten them into one or at least extract "Library project" and connect it as .aar
As a result, our build time decreased to about minute - minute and a half. Hope these suggestions will help you too.
And if we will talk about small changes, starting from Android Studio 2.0, it is possible to use Instant run and Incremental build, which makes small changes in method or layout even faster.
Understand that Gradle Build has nothing to do with your CPU Speed or RAM. The reason why the Build gets slower in your PC is due to your Internet Connection. The build can take nearly ~100 MB approx. of data to complete it's process. Even if your Internet Connection is fast and your connection's PING speed is slow, it takes more time.

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.

Painfully slow make with IDEA 12.0

I love the new incremental Java compile in IDEA 12.0 but there seems to be a price to pay. Making now takes about twice as long as in 11.x, most of the time appearing to be spent
Executing DEX
(according to the status bar).
I can take a 12.0 project, revert to 11.x and making is back to "normal speed" (approx 4 minutes vs 30 seconds).
I don't get this. AFAIK, IDEA (or Eclipse or any other IDE) is just shelling out to dx.jar to compile the Dalvik executable. If there was a problem with the ADT, it would affect 11.x equally.
OS is Win 7 Ultimate. 3.2GHz quad core with 16GB but I suspect that the issue is not related to OS or PC since 11.x is OK.
Any ideas? I'll log a bug with Jetbrains but wanted to see if anyone has more concrete info or workarounds? There's nothing so far on the Jetbrains bug tracker or fora that I can find.
I have had this issue a couple of times in the past and it's always been due to the inclusion of a global library that hangs during build.
On one occasion it was due to the Python libraries trying to execute when the Android project was built because I had a python file in my Android project and IntelliJ decided to add the Python runtime libs to my project dependencies.
More recently the same thing happened with Groovy when I had a gradle file in the Android project.
For me I simply removed these dependencies from the project and the problem resolved itself.
In my case I discovered this by force killing (kill -9) the java process that was running the make. This caused intellij to dump the error to the Messages view in the IDE where I could see groovy trying to execute.

Categories

Resources