Android Studio 2.3.3 stucks when first run
Asked Answered
D

10

12

I downloaded Android Studio 2.3.3 for Linux and unzipped the content to /usr/local then

$ cd android-studio/bin

Edited the file idea.properties and appended a following line to it:

disable.android.first.run=true

Then launched Android Studio:

$ sudo sh studio.sh

Looking in classpath from com.intellij.util.lang.UrlClassLoader@1a7cec2 for /com/sun/jna/linux-x86/libjnidispatch.so
Found library resource at jar:file:/usr/local/android-studio/lib/jna.jar!/com/sun/jna/linux-x86/libjnidispatch.so
Trying /root/.AndroidStudio2.3/system/tmp/jna5562911082428971611.tmp
Found jnidispatch at /root/.AndroidStudio2.3/system/tmp/jna5562911082428971611.tmp
[  40066]   WARN - dea.updater.SdkComponentSource - File /root/.android/repositories.cfg could not be loaded. 
^C[18124266]   WARN - pl.local.NativeFileWatcherImpl - Watcher terminated with exit code 130 

And it will stuck. After long waiting I termited it with Ctrl+C

Disbranch answered 1/7, 2017 at 7:43 Comment(10)
Are your running as root?Showpiece
@Showpiece With root the result is the same.Disbranch
Non, you should not run as root. But I find it odd that it tries to access /root/.android/repositories.cfgShowpiece
I think the corresponding repository are not available at the pathMaurer
remove this line disable.android.first.run=trueArenaceous
@UpendraShah The result is the same.Disbranch
@Disbranch Why you edited idea.properties??Arenaceous
@UpendraShah I googled similar problem and in that case this helped.Disbranch
Why do you run studio as root?? Don't do it. No need to install as root, and not run as rootRemex
I think my answer below will fix the issueRemex
R
2

I think all your problems happen because you ran as root (sudo) on your first run.

So try to unroot before doing a clean install like I suggest below:

Unroot the installation

  1. cd to the folder where you unzipped Android Studio before

  2. cd ..

  3. Recursively change user and group:

    sudo find <thedirname> -print0 | xargs -0 chown <yourusername>:<yourgroupname>
    
  4. cd ~ or cd to go back to home

  5. Recursively change user and group

    sudo find .Android* -print0 | xargs -0 chown <yourusername>:<yourgroupname>
    

    (I sudo because you've used root user previously).

  6. Recursively change user and group

    sudo find Android* -print0 | xargs -0 chown <yourusername>:<yourgroupname>
    
  7. cd into the unzipped directory. Do chmod +x studio.sh.

  8. Start Android Studio ./studio.sh

If it didn't help, do a:

Clean install

  1. Download and unzip a fresh copy of Android Studio. I suggest version 3, it's pre released, but stable. It doesn't matter where you put it.

  2. I believe you have Java installed, but make sure you have Java 8 as the default one: in command line: java -version, make sure it's 1.8.

  3. Move any old installations out of the way, in case they are corrupt:

    sudo mv ~/.Android* ~/tmp/
    sudo mv ~/Android ~/tmp/
    

    should do the trick. (I sudo because you've used root user previously).

  4. cd into the unzipped directory. Do chmod +x studio.sh.

  5. Start Android Studio ./studio.sh

Make sure all the files are owned by your username, and group as well.

Remex answered 19/7, 2017 at 11:51 Comment(1)
Yesterday, I tried the first sequence of steps of your answer, but ended it after ten minutes because lack of time and tried the second sequence of steps. I'm back here today and it worked. So, the second sequence certainly works. Thank you for such a precise, complete answer.Disbranch
T
5

Try attaching to the process with strace to see what it's doing (for example, waiting on a network or file). Or run it with strace like this:

strace -o foo.log -s1024 -f ./studio.sh

After a while, break it with Ctrl-C and examine the log file for syscalls like open, read, recvmsg.

Alternatively, while it's running, you can attach with a Java profiler to the jvm. For a start, you can launch jconsole or jvisualvm and attach to the Android Studio (it will show as an empty name, with only PID) and view stack traces of individual threads. In jvisualvm you can view the CPU usage sample and click on the hot event and see the stack trace.

Basically you need to find out what the app is trying to access for so long. Most likely some network resource.

Taw answered 16/7, 2017 at 22:12 Comment(6)
I did strace and it's full of syscalls like "open, "read", "recvmgs".Disbranch
Could you please describe the instructions for jconsole or jvisualvm in more specific steps? (I don't have experience with these tools).Disbranch
@Disbranch have you looked for errors in the strace log, especially for calls like open/socket/read? Do you see what files or network resources it tries to access?Taw
@Disbranch For jvisualvm, just run the command (you might need to install the "visualvm" package), then double-click the "Android Studio", go to "Sampler" -> "CPU" and look at the top entries in the table. You can press "Thread dump" to see stack traces.Taw
I have also noticed you run with "sudo". Does running as a non-root without "sudo" work? Do other apps such as "gedit" run with "sudo"? If not, run "xhost +" as your default non-root user from terminal.Taw
Thank you for comments, I noticed only one of them before, because a lot of activity on this question. auval solved it, but every answer is useful here.Disbranch
S
2

I took some information from:

The answers collectively say that:

Android Studio will run fine without repositories.cfg.

You can remove this warning by putting the following into repositories.cfg:

### User Sources for Android SDK Manager
count=0

After waiting some time it eventually goes beyond that step.

Patience is the key.

So, try waiting a little bit more. It always helps.

Sinapism answered 16/7, 2017 at 8:26 Comment(8)
What is little bit more? (e.g. in minutes)Disbranch
I don't know, but gradle is famous for its slowness.Sinapism
I terminated it after 18 hours.Disbranch
@Disbranch wow. Gradle is slow, but I did not know that it is so slow.Sinapism
I use 2 GB of RAM on my laptop, but hope this is not the cause.Disbranch
It might not be the cause but it would be the cause of lots of headaches afterwards. My laptop had 4GB of RAM and a 2.5GHz processor and it took me hours to be able to write a few lines of code, and let's forget about the emulation...Lexicography
@Shinratensei And are you on Linux? I would like to get familiar with the Android Studio and use it for GUI (layouts) and for code primarily vim editor.Disbranch
No, sorry, I use it on Windows 10.Lexicography
U
2

This is common. On your first run the gradle files are needed to be downloaded and installed in background. It's about 90 MB in size and even if your internet speed is high, the gradle servers may be slow taking it to maximum of 1 or 2 hours in the worst case. So open Android Studio and wait until it opens. Hope it helps.

Underplot answered 16/7, 2017 at 9:24 Comment(3)
OK, I'll let it running. I didn't have an idea that this could take so long without giving a response to the user, what is happening.Disbranch
No, after two hours it's still running.Disbranch
Now, it's about 18 hours, so I terminate it.Disbranch
R
2

I think all your problems happen because you ran as root (sudo) on your first run.

So try to unroot before doing a clean install like I suggest below:

Unroot the installation

  1. cd to the folder where you unzipped Android Studio before

  2. cd ..

  3. Recursively change user and group:

    sudo find <thedirname> -print0 | xargs -0 chown <yourusername>:<yourgroupname>
    
  4. cd ~ or cd to go back to home

  5. Recursively change user and group

    sudo find .Android* -print0 | xargs -0 chown <yourusername>:<yourgroupname>
    

    (I sudo because you've used root user previously).

  6. Recursively change user and group

    sudo find Android* -print0 | xargs -0 chown <yourusername>:<yourgroupname>
    
  7. cd into the unzipped directory. Do chmod +x studio.sh.

  8. Start Android Studio ./studio.sh

If it didn't help, do a:

Clean install

  1. Download and unzip a fresh copy of Android Studio. I suggest version 3, it's pre released, but stable. It doesn't matter where you put it.

  2. I believe you have Java installed, but make sure you have Java 8 as the default one: in command line: java -version, make sure it's 1.8.

  3. Move any old installations out of the way, in case they are corrupt:

    sudo mv ~/.Android* ~/tmp/
    sudo mv ~/Android ~/tmp/
    

    should do the trick. (I sudo because you've used root user previously).

  4. cd into the unzipped directory. Do chmod +x studio.sh.

  5. Start Android Studio ./studio.sh

Make sure all the files are owned by your username, and group as well.

Remex answered 19/7, 2017 at 11:51 Comment(1)
Yesterday, I tried the first sequence of steps of your answer, but ended it after ten minutes because lack of time and tried the second sequence of steps. I'm back here today and it worked. So, the second sequence certainly works. Thank you for such a precise, complete answer.Disbranch
T
1

I've found a potientaly useful link from AskUbuntu, the guy suggested creating an empty file called repositories.cfg. And that solved it.

Ref: https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded

Tourneur answered 7/7, 2017 at 11:36 Comment(1)
Maybe on a fresh install?Tourneur
T
1

Just remove /root/.AndroidStudio2.3 and /root/.android (after making a backup)

Tanaka answered 10/7, 2017 at 9:51 Comment(0)
D
1

Maybe it has something to do with the script looking at the root location. Have you tried using chown on the unzipped content directory?

Diplex answered 13/7, 2017 at 12:57 Comment(0)
A
1

Try this to install

Download the studio

Extract to home

go to android-studio/bin/

Mouse right click than open terminal

type ./studio than press enter

now it will start to install studio. If you installing first time than It will download some files of SDK. and if you have already downloaded SDK than you can cancel download and set you SDK path from the setting from right bottom corner.

Arenaceous answered 17/7, 2017 at 17:27 Comment(0)
B
1

try creating repositories.cfg -- Because I see it as warning. Let's see what happens after that!

touch ~/.android/repositories.cfg /* Linux */
Balky answered 18/7, 2017 at 7:5 Comment(1)
Didn't helped.,Disbranch
S
0

Extract your downloaded Android Studio setup zip file to your /home/<user_name> directory and in terminal follow the below commands

$ sudo chmod +x studio.sh

And hit enter Now run the following command

$ ./studio.sh

And wait for some time to download the required libraries.

Sanguineous answered 16/7, 2017 at 14:1 Comment(4)
The OP did exactly that.Sinapism
Yeah. But I suggested that to use /home directory and change the file execution with chmod command. The OP did not try with this I guess.Sanguineous
There are some other answers that did not help but advised to use chown & the OP launched the file somehow, that means it's already an executable.Sinapism
Yes, I tried both ./studio.sh and sh studio.sh. These are access rights of the file studio.sh -rwxr-xr-x 1 root root now.Disbranch

© 2022 - 2024 — McMap. All rights reserved.