可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
回答1:
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
cd
to the folder where you unzipped Android Studio before
cd ..
Recursively change user and group:
sudo find <thedirname> -print0 | xargs -0 chown <yourusername>:<yourgroupname>
cd ~
or cd
to go back to home
Recursively change user and group
sudo find .Android* -print0 | xargs -0 chown <yourusername>:<yourgroupname>
(I sudo
because you've used root
user previously).
Recursively change user and group
sudo find Android* -print0 | xargs -0 chown <yourusername>:<yourgroupname>
cd
into the unzipped directory. Do chmod +x studio.sh
.
Start Android Studio ./studio.sh
If it didn't help, do a:
Clean install
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.
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
.
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).
cd
into the unzipped directory. Do chmod +x studio.sh
.
Start Android Studio ./studio.sh
Make sure all the files are owned by your username
, and group as well.
回答2:
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.
回答3:
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.
回答4:
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.
回答5:
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
回答6:
Just remove /root/.AndroidStudio2.3
and /root/.android
(after making a backup)
回答7:
Maybe it has something to do with the script looking at the root
location. Have you tried using chown
on the unzipped content directory?
回答8:
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.
回答9:
try creating repositories.cfg -- Because I see it as warning. Let's see what happens after that!
touch ~/.android/repositories.cfg /* Linux */
回答10:
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.