9

I have a simple app and every time I hit "run" it takes more than 3 minutes for gradle to finish build and load the app. And it happens on both emulator and my android phone. And before you mark this post as a similar post, hear me out: I have been tying to troubleshoot the issue since last 10 days. I have gone through more than 20 stack overflow similar questions (like this one) and dozens of articles on google and I've tried every solution they suggested but nothing seems to work. Here is what I've tried so far:

  • Added org.gradle.parallel=true and org.gradle.daemon=true to gradle.properties
  • Added --parallel and --offline to command line option settings
  • Enabled "offline work" in settings
  • Enabled/Disabled "instant run" - didn't make any difference
  • I've allocated a lot of memory: org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
  • I've completely disabled Windows Defender
  • I am using latest version of gradle (2.10) and latest version of Android Studio which is 2.1.1 Even after trying all these, it still takes more than 3 minutes and it is getting very frustrated.

When app is running for several minutes, I've noticed :app:processDebugResources in gradle console. So maybe this might be causing the slow down, I don't know. Also, I have an xml file that I am parsing and that xml file has about 70,000 lines in it. Could this be causing any problem? Could it be Windows 8?

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

8
  • 1
    What are your system configurations? Which Java version and provider are you using? What is your system architecture? Commented Jun 3, 2016 at 2:49
  • 1
    +1 for the clear post and research effort. Regarding your 70k liner xml file. Are you parsing in the beginning of the app itself? It might be the reason. Commented Jun 3, 2016 at 2:51
  • And, I'm parsing the XML when user clicks a button not when app loads Commented Jun 3, 2016 at 2:55
  • 2
    Try really latest gradle 2.13 also Commented Jun 3, 2016 at 3:24
  • 1
    Run the gradle build with --debug option. It will show you what it is doing exactly. Commented Jun 3, 2016 at 6:27

1 Answer 1

1

I have found out why this was happening. It was because I was parsing the XML in the onCreate function() and since the XML had 70,000 lines, the compiler was taking long time. But after moving the file to "assets" folder, the problem has solved. It was my mistake and had nothing to do with gradle settings but if someone stumbles upon a similar issue, I recommend you to try all the things I've listed above and your gradle build should run faster.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.