Why does building app in Android Studio take so long? - android

I've been using Android Studio for the past few months, and I've noticed that it's a lot slower to build an app than Eclipse. For instance, in Eclipse, if I were to modify a line of code and then re-build, it would take less than 10 seconds. The same act in the same project in Android Studio causes the build process to last more than a minute (sometimes 2). Is there any setting or configuration I can change to help with this? Is it gradle related?

Related

Android studio taking very long time for build project After Android Studio Arctic Fox Update

look how much time it's taking just for normal build
Please help me out if you got Any solution
My first build after update took about 6 mins and it got quicker later on, so I guess the first few builds might take some time. Later on its all good.
Its recommended to restart android studio after the first build is complete.

Android Studio Canary freezes all the time on Windows 10 64-bit

I am currently developing an Android App. Four days ago I messed up the Git repository I was working with and I decided to create a new Android Studio project and clone the repository inside this new project.
Since then Android Studio freezes like every 2 - 10 Minutes. I even installed Canary 12 for that reason, I tried to remove everything I found regarding Android on my Computer before! Nevertheless, I still get those freezes.
I already set memory to maximum. At the time Android Studio crashes the total memory consumption is not above 50%, so it can't be a memory problem (in my opinion) - any ideas?
I would try File > Invalidate cache and restart, maybe disable all non included extensions. if that does not work try restarting your computer and/or reinstall android studio.

Android gradle build time exponential increase

My Gradle build time is usually around 12 seconds, but after around 10 - 20 builds it starts to increase at once, exponentially: 30 seconds, 50 seconds, 2 minutes, 5 minutes, etc. up to out of memory.
Healthy build:
:app:compileDev21DebugJavaWithJavac 4.783s
:app:transformClassesWithRealmTransformerForDev21Debug 3.011s
:app:transformClassesWithDexForDev21Debug 2.133s
:app:compileRetrolambdaDev21Debug 1.325s
:app:packageDev21Debug 0.997s
:app:processDev21DebugResources 0.703s
After 10 - 20 of those, it starts increasing:
:app:transformClassesWithDexForDev21Debug 39.172s
:app:compileDev21DebugJavaWithJavac 34.221s
:app:packageDev21Debug 9.922s
:app:transformClassesWithRealmTransformerForDev21Debug 8.353s
:app:compileRetrolambdaDev21Debug 3.120s
:app:fabricGenerateResourcesDev21Debug 1.376s
As you can see, every task increases in time.
I use Android Studio 2.2.2, but I had the problem since the last 3 versions or so. Gradle 2.14.1. Probably it’s related to our project. I use Mac, my colleague on Windows has the same on the same project. If I stop AS, kill Java and start AS again, that solves it for a while.
I am not using the Jack compiler (yet).
To be clear: my build time is NOT generally slow: 13 seconds is fine. This is not a duplicate of all the "slow build time" questions. Only after 10 - 20 builds the build time increases exponentially with every build.
Update: Make Gradle build "offline" didn't help. Using "gradle-3.1-all.zip" (distributionUrl in grade-wrapper.properties) also did not help.
Anyone had this problem and knows a solution?
I experienced(and somehow still facing) the same issue. There are some fixes that you can try.
1- Make Gradle build Offline.
2- Install Gradle on machine and use local installation alongside Offline work checked in Android Studio instead of Using wrapper which connects to proxy and takes more time with building cache of Studio.
I followed this and this article and it helped me not substantially but enough to get me nearly 6,7 hours of continuous development on 8GB memory system then i have to Invalidate and Restart.
It is fixed since the day that I removed Fabric (CrashLytics) and replaced it with FireBase Crashes. Fabric was most probably causing it, but I'm not 100% sure.

How to android studio run fast?

I have a large program in android studio 2.1.0.9. Every time that i want to run my app in android studio I should stay more than 1 hour. How can I speed up it?I also did all step in http://www.viralandroid.com/2015/08/how-to-make-android-studio-fast.html but did not solve my problem

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