Android Studio: Gradle Build in 3 Minutes

I have a simple application, and every time I click run, it takes more than 3 minutes for gradle to complete the build and load the application. And this happens both on the emulator and on my Android phone. And before you mark this message as a similar message, listen to me: I am contacting to fix the problem from the last 10 days. I survived more than 20 stack overflows of similar questions (like this one) and dozens of articles on Google, and I tried every solution he proposed, but nothing worked, Here's what I have tried so far:

  • Added org.gradle.parallel=true and org.gradle.daemon=true in gradle.properties
  • Added --parallel and --offline for command line options
  • Enable "battery life" in the settings
  • Enabled / Disabled "instant start" - does not matter.
  • I allocated a lot of memory: org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF- 8
  • I completely disabled Windows Defender
  • I am using the latest version of gradle (2.10) and the latest version of Android Studio, which is 2.1.1. Even after you have tried all this, it takes more than 3 minutes and it is very frustrating.

When the application runs for several minutes, I noticed :app:processDebugResources in the gradle console. Perhaps this can lead to a slowdown, I do not know. In addition, I have an xml file that I am processing, and this XML file contains about 70,000 lines. Could this be causing any problems? Maybe Windows 8?

Please provide any suggestions on how to fix this. Thanks:)

+8
android android-studio build.gradle gradle
source share
1 answer

I found out why this is happening. This was because I was parsing XML into onCreate () functions, and since XML had 70,000 lines, the compiler took a lot of time. But after moving the file to the "assets" folder, the problem is resolved. It was my mistake and had nothing to do with gradle settings, but if someone came across a similar problem, I recommend that you try all the things listed above, and your gradle build should work faster.

+1
source share

All Articles