简体   繁体   中英

Why is Gradle taking so long to build?

My Gradle build is taking between 1 minute and 2 minutes and I'm uncertain what's going on. On Event Log I see a single entry most of the time

Executing tasks: [:app:generateDebugSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:assembleDebug]

I have no idea what this task is doing, I've checked work offline setting hoping this to make a difference but I had no luck.

Pass the --profile option to Gradle to profile build execution time and generate a report in the <buildDir/reports/profile directory. For more information see the docs about Profiling a build .

Gradle build time depends on a lot of factors and may get slower as the codebase of your project grows, you add more third-party dependencies.

For instance if you use Google Play Services dependencies, you can break those apart and only use the specific dependency you need.

For example try to use

compile 'com.google.android.gms:play-services-maps:8.4.0'

instead of

compile 'com.google.android.gms:play-services:8.4.0'

This is just an example which is misused by a lot of people but as I said it's usually based on how large your codebase is. And obviously the hardware configurations, your machine have..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM