Why Android Studio rebuilds project so slow even when no changes in sources?

后端 未结 4 466
后悔当初
后悔当初 2021-02-05 07:05

When I make some changes in source code, Android Studio (actually gradle) needs to rebuild the project. It\'s obvious.

Why the second build takes almost the sam

相关标签:
4条回答
  • 2021-02-05 07:09

    Finally, I found the solution: turn on Offline work for gradle.

    enter image description here

    or using CLI:

    ./gradlew --offline assembleDebugOrWhatever

    0 讨论(0)
  • 2021-02-05 07:09

    To avoid rebuild EACH TIME, i'm going to my module project settings -> Dependencies and up or down one of my library item -> Apply -> Ok -> Make regenerating R.java. You could also try unchecking "Use external build" in compiler settings:

    File -> Settings (Ctrl+Alt+S) -> Compiler -> Uncheck "Use external build"

    0 讨论(0)
  • 2021-02-05 07:17

    Does the gradle console say :app:assemeble UP-TO-DATE ?

    If you take a look at the run configuration, you might notice at the very bottom Before Launch: Gradle-aware Make

    This is just telling it to recompile(if necessary) before running, but that detection is delegated to Gradle. Gradle will only actually recompile if it detects that it needs to, but the assemble task must still attempt to run to detect UP-TO-DATEness. So it says it's running it, but its not actually doing anything. When I run it two times in a row, the first time it takes a while to do everything, BUT the second time it just runs through the task list pretty quickly (with a bunch of UP-TO-DATEs) and deploys to phone/emulator.

    0 讨论(0)
  • 2021-02-05 07:18

    This isn't a problem per se. And it has nothing to do with Android Studio since Gradle is just an Android Plugin that helps you build your projects. You need to fully understand what gradle does to know why Android Studio uses it whenever you run your apps. Take a look at this nice SO question on gradle and the android developer website's article on it. Finally, from my personal experience,when it comes to dealing with Android Studio and Eclipse for Android development, you need to be a little patient. Hope this helps in some way.

    0 讨论(0)
提交回复
热议问题