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

u32i64
  • 2,384
  • 3
  • 22
  • 36
xralf
  • 3,312
  • 45
  • 129
  • 200

10 Answers10

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.

u32i64
  • 2,384
  • 3
  • 22
  • 36
alexst
  • 591
  • 2
  • 6
  • I did `strace` and it's full of syscalls like "open, "read", "recvmgs". – xralf Jul 17 '17 at 06:53
  • Could you please describe the instructions for jconsole or jvisualvm in more specific steps? (I don't have experience with these tools). – xralf Jul 18 '17 at 14:57
  • @xralf 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? – alexst Jul 18 '17 at 23:30
  • @xralf 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. – alexst Jul 18 '17 at 23:41
  • 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. – alexst Jul 18 '17 at 23:42
  • 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. – xralf Jul 20 '17 at 05:41
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.

u32i64
  • 2,384
  • 3
  • 22
  • 36
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.

Praveen Thirumurugan
  • 977
  • 1
  • 12
  • 27
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.

u32i64
  • 2,384
  • 3
  • 22
  • 36
Amir Uval
  • 14,425
  • 4
  • 50
  • 74
  • 2
    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. – xralf Jul 20 '17 at 05:34
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

Ohad Rubin
  • 460
  • 3
  • 13
1

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

Anton Malyshev
  • 8,686
  • 2
  • 27
  • 45
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?

Sandeep Neupane
  • 148
  • 1
  • 6
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.

Community
  • 1
  • 1
Upendra Shah
  • 2,218
  • 17
  • 27
1

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

touch ~/.android/repositories.cfg /* Linux */
Uddhav P. Gautam
  • 7,362
  • 3
  • 47
  • 64
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.

Shashanth
  • 4,995
  • 7
  • 41
  • 51
  • The OP did exactly that. – u32i64 Jul 16 '17 at 16:37
  • 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. – Shashanth Jul 16 '17 at 16:54
  • 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. – u32i64 Jul 16 '17 at 17:00
  • 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. – xralf Jul 17 '17 at 15:39