Search code examples
macosandroid-studio-3.0macos-mojave

AndroidStudio 3.2 slow startup on Mojave


I downloaded the last version of Android Studio for my mac. It took about 60 seconds to startup without any project to index!

I've modified the vm option file in this way

-Xms512m
-Xmx2560m
-XX:MaxPermSize=700m
-XX:ReservedCodeCacheSize=480m
-XX:+UseCompressedOops
-Dfile.encoding=UTF-8
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
-Djna.boot.library.path=

-da
-Xverify:none

-XX:ErrorFile=$USER_HOME/java_error_in_studio_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_studio.hprof

But it's still the same

Any suggestion will be appreciated

MacBook Pro specs :

MacBook Pro (Retina, 15-inch, Mid 2014)
Processor : 2,5 GHz Intel Core i7
RAM : 16 GB 1600 MHz DDR3
Graphics : Intel Iris Pro 1536 MB
Storage : SSD 500GB

Solution

  • I found a solution by adding my Mac hostname on the /etc/hosts file mapped to the 127.0.0.1 address as well as the ::1 like this:

    127.0.0.1   localhost Macbook-1389.local
    ::1         localhost Macbook-1389.local
    

    It seems to depend on JVM. Probably it takes a long time to resolve ip-address for localhost.

    Fast solution

    sudo sed -i bak "s^127\.0\.0\.1.*^127.0.0.1 localhost $(hostname)^g" /etc/hosts
    sudo sed -i bak "s^::1.*^::1 localhost $(hostname)^g" /etc/hosts
    sudo ifconfig en0 down
    sudo ifconfig en0 up