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:
org.gradle.parallel=true
and org.gradle.daemon=true
to gradle.propertiesorg.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-
8When 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 :)
Dynamic Dependencies slow down your build since they keep searching for the latest builds every time. To improve the performance we need to fix the version in place. Use only those dependencies that you need. For example google maps dependency, instead of importing compile 'com.
Check your Internet connection. If internet speed is very slow gradle build will also take long time to build. I check by change my wifi internet connection with another one good speed connection. Now build time is normal.
Gradle builds are used to define a project and its tasks. At least one Gradle build file is located in the root folder of the project. A task represents the work that a Gradle build has to perform, e.g., compiling the source code of the program. You can execute multiple tasks at a time under one build file.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With