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

前端 未结 28 1907
太阳男子
太阳男子 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:04

    To run Android envirorment on low configuration machine.

    1. Close the uncessesory web tabs in browser
    2. For Antivirus users, exclude the build folder which is auto generated
    3. Android studio have 1.2 Gb default heap can decrease to 512 MB Help > Edit custom VM options studio.vmoptions -Xmx512m Layouts performace will be speed up

    4. For Gradle one of the core component in Android studio Mkae sure like right now 3.0beta is latest one

    Below tips can affect the code quality so please use with cautions:

    1. Studio contain Power safe Mode when turned on it will close background operations that lint , code complelitions and so on.

    2. You can run manually lintcheck when needed ./gradlew lint

    3. Most of are using Android emulators on average it consume 2 GB RAM so if possible use actual Android device these will reduce your resource load on your computer. Alternatively you can reduce the RAM of the emulator and it will automatically reduce the virtual memory consumption on your computer. you can find this in virtual device configuration and advance setting.

    4. Gradle offline mode is a feature for bandwidth limited users to disable the downloading of build dependencies. It will reduce the background operation that will help to increase the performance of Android studio.

    5. Android studio offers an optimization to compile multiple modules in parallel. On low RAM machines this feature will likely have a negative impact on the performance. You can disable it in the compiler settings dialog.

    0 讨论(0)
  • 2020-11-22 09:05

    You could make the process faster, if you use gradle from command line. There is a lot of optimization to do for the IDE developers. But it is just an early version.

    For more information read this discussion on g+ with some of the devs.

    0 讨论(0)
  • 2020-11-22 09:05

    Hi I know this is very very late answer but maybe help someone
    in my case I was using

    compile 'com.android.support:support-v4:23.1.1'
    

    in my app Gradle dependency
    but in one of my libraries it was

     compile 'com.android.support:support-v4:23.0.1'
    

    after change all to latest version my problem solved.

    0 讨论(0)
  • 2020-11-22 09:06

    Following the steps will make it 10 times faster and reduce build time 90%

    First create a file named gradle.properties in the following directory:

    /home/<username>/.gradle/ (Linux)
    /Users/<username>/.gradle/ (Mac)
    C:\Users\<username>\.gradle (Windows)
    

    Add this line to the file:

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

    And check this options in Android Studio

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