Android Studio using 100% CPU on an i7 processor for project Rebuild

后端 未结 4 1919
故里飘歌
故里飘歌 2021-02-05 12:19

My Windows 7 machine has a quad core i7 processor. When I Rebuild my project, it takes on average 25 seconds. And when I launch the app, it takes on average 36 seconds (before

4条回答
  •  庸人自扰
    2021-02-05 12:38

    Here are the three improvements I was able to make:

    I was preDexing my JARs every time I built the project, so I found this solution:

    dexOptions {
        preDexLibraries = false
    }
    

    I was using the entire Google Play Services library:

    compile('com.google.android.gms:play-services:+') {
        exclude module: 'support-v4'
    }
    

    When all I needed was Google Cloud Messenger:

    compile('com.google.android.gms:play-services-gcm:+') {
        exclude module: 'support-v4'
    }
    

    In Eclipse, I would always do a Rebuild and then launch app with the play button. In Android Studio, now I am just doing a Clean and then launch app with the play button. Also the Run button in Android Studio does NOT work every time right after the Clean. This was causing what seemed to be delays because nothing was happening. So now I leave the Gradle Console open to make sure that the run button is working, and when it doesn't I just hit it a second time.

    What I used to have:

    Rebuild: 26 seconds
    Launch:  36 seconds
    Install: 15 seconds
    

    and now:

    Clean:    8 seconds
    Launch:  22 seconds
    Install: 15 seconds
    

    which is a major improvement! Hopefully this helps someone else.

提交回复
热议问题