Can I prevent the Android Studio build speed from getting slower? - android

I don't want to know how to speed up my Android Studio (1.1) build time in general.
Actually it's okay but only until the first 〜10 builds to an Android device/emulator. Then I usually restart Android Studio and the build speed is fine again. I just can't believe this what it should be.
For my current app I measured a build time of around 28 seconds for the first 10 runs and then for the 11th I measured 39 seconds and for the 12th 3 minutes and 16 seconds.
How can it be that it is getting this much slower and is there a possibility to prevent it?

there are some tricks to improve your Android Studio performance:
Activate gradle deamon: https://www.timroes.de/2013/09/12/speed-up-gradle/
Activate Compiler features: Settings -> Compiler, then activate "Compiler independent...", "Use in-process build" and "Configuration on demand".
With these two tricks you'll feel the difference. Let me know.
Cheers!

In android Studio
Go to > File > Settings > in Build Go to > Compiler
and add the content in VM Options: --Xmx2048 --XX:MazPermSize=512m
and in Command-line Options: --offline
this think build your project with in a second

Related

Gradle Build Running since 57 Minutes?

I am sorry if this question is repeat but gradle is taking much longer time then before. It is running since 57 min as you can see in screenshot and in previous attemp it took only one or half minute and usually it builds app in 2-3 minutes maximum. But from 2,3 days it behaving strangely. Running forever without any reason. Any help?
In Android Studio go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Check 'Offline work' under 'Global Gradle settings'
It will reduce 90% gradle build time.
While offline builds and reinstall may be a solution, we still need to get down to the exact reason.
Is it possible for you to run the gradle command with a stacktrace or a debug info? Even if the build hangs sporadically, you lose nothing by putting out a debug log. At best, there will some information which can be analyzed further.

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.

Xamarin.Android builds/deployments are very slow. How to speed them up?

We have a large Xamarin.Android project with two depending projects and a bunch of third party dll's. Doing a debug deployment (without any changes) onto a Hax-x86 Emulator or a Nexus 5 device is painfully slow (> 80 seconds). For comparison the Xamarin.iOS version of the App deploys in under seven seconds onto a real device.
To test the deployment times I've also created a fresh Xamarin.Android project which deploys in about four seconds. When I add a depending project, the deploy time goes up to seven seconds. When I add a layout file to the depending project the deployment time increases to about ten seconds.
Is it possible to speed the Android build and deployment up with Xamarin Studio? A big Eclipse Android Projects is deployed rather quick in comparison.
Update:
Just running the installation build step takes about 40 seconds:
time xbuild /t:Install BigApp.csproj
...
...
...
Time Elapsed 00:00:42.8526970
about half the time is spend where the above command prints to console:
Target _CompileDex:
JavaSourceFiles:
JavaLibraries:
ExternalJavaLibraries:
Tool /usr//bin/java execution started with arguments: -Xmx512M -jar
/Users/myname/Library/Developer/Xamarin/android-sdk-mac_x86/build-tools/17.0.0//lib/dx.jar
--no-strict --dex --output=obj/Debug/android/bin/classes.dex obj/Debug/android/bin/classes
/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/platforms/android-15/mono.android.jar
/Users/myname/Projects/BigApp/obj/Debug/__library_projects__/TestFlightBindings.Jars.TestFlightLib_1_2.jar
/Users/myname/Projects/BigApp/obj/Debug/__library_projects__/android-support-v4.jar
/Users/myname/Projects/BigApp/obj/Debug/__library_projects__/classes.jar
/Users/myname/Library/Developer/Xamarin/android-sdk-mac_x86/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar
When I run the solution from Xamarin Studio this step happens twice. Once for the depending project and once for the main project. I tried to reproduce this behavior on the console with
"/Applications/Xamarin Studio.app/Contents/MacOS/mdtool" -v build "--configuration:Debug -t Install" "BigApp.sln"
but that only builds the main project.
Update:
I created a small demo project with very slow deployment time:
https://github.com/perpetual-mobile/SlowAndroidDeploymentWithXamarin
I contacted the Xamarin guys about this problem and they fixed two issues in Xamarin.Android:
https://bugzilla.xamarin.com/show_bug.cgi?id=16622 (provided since Xamarin Android 4.12.0)
https://bugzilla.xamarin.com/show_bug.cgi?id=15162 (provided since Xamarin Android 4.10.0)
The build time for my huge project without any changes is now ~5 seconds. And when making a code change in the deepest depending lib a deploy cycle does not take longer than 16 seconds.

Categories

Resources