Building and running app via Gradle and Android Studio is slower than via Eclipse

前端 未结 28 1902
太阳男子
太阳男子 2020-11-22 08:21

I have a multi-project (~10 modules) of which building takes about 20-30 seconds each time. When I press Run in Android Studio, I have to wait every time to rebuild the app,

28条回答
  •  清酒与你
    2020-11-22 09:01

    Here's what helped this beginning Android programmer (former professional programmer, years ago) in speeding up Android Studio 2.2. I know this is a rehash, but, just summarizing in one place.

    Initial builds can still be brutally slow, but restarts of running apps are now usually very tolerable. I'm using a sub-optimal PC: AMD Quad-Core A8-7410 CPU, 8MB RAM, non-SSD HD, Win 10. (And, this is my first Stack Overflow posting.... ;)

    IN SETTINGS -> GRADLE:

    yes for "Offline work" (this is perhaps the most import setting).

    IN SETTINGS -> COMPILER:

    yes for "Compile independent modules in parallel" (not sure if this does in fact help utilize multicore CPUs).

    IN GRADLE SCRIPTS, "build.gradle (Module: app)":

    defaultConfig {
        ...
       // keep min high so that restarted apps can be hotswapped...obviously, this is hugely faster.
       minSdkVersion 14
       ...
        // enabling multidex support...does make big difference for me.
        multiDexEnabled true
    

    ALSO IN GRADLE SCRIPTS, "gradle.properties (Project Properties)":

    org.gradle.jvmargs=-Xmx3048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

    org.gradle.parallel=true org.gradle.daemon=true

    Additionally, testing on a physical device instead of the emulator is working well for me; a small tablet that stands up is convenient.

提交回复
热议问题