Low speed when the output in Android Studio - android

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.

Related

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.

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

How to prevent Android Studio 2.0 from doing a complete clean build after uninstalling app from device?

I've been using Android Studio 2.0 Beta 5 with Gradle plugin 2.0.0-beta5. I've had Instant Run feature enabled, which is very useful when I want to do a quick change-and-test. Because it usually needs 50 seconds for my project to do a complete :assembleDebug. With Instant Run, I've been able to get my changed code running on device within about 10 seconds.
However, when I need to remove the app from the test device and have a complete new install. Android Studio always do the following thing when I click the "Run" button for the next time:
:clean, :generateDebugSources, :generateDebugAndroidTestSources, :prepareDebugUnitTestDependencies, :mockableAndroidJar, :assembleDebug
This is very slow. It takes up about 2 minutes for my project.
Is there a way to disable this behaviour? Or why is it not possible?
The instant run, in order to be faster only target the API of the selected device.
Instant run uses different techniques to perform hot, warm, and cold swaps that
are specific to the API level of the target device
Instant run ref.
But if you just need to push the apk again, you can use the gradle task install... (in general install+Flavor+Type i.e.:installProdRelease installPaidDebug) or use ADB to install your APK manually.
Got the same problem.
Fixed by turning off Instant Run
(File -> Settings -> Build, Execution, Deployment -> Instant Run)

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.

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

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

Categories

Resources