- Download the Android Package of Linux from Android Studio,
- android-studio-bundle-130.737825-linux.tgz for Linux platform
- Copy to /usr/locate
- Unpackage to intall
- Android-studio's startup script --- "studio.sh"
1 #!/bin/sh
2 #
3 # ---------------------------------------------------------------------
4 # Android Studio startup script.
5 # ---------------------------------------------------------------------
6 #
7 message()
8 {
9 TITLE="Cannot start Android Studio"
10
11 //[ -t FD ] 如果文件描述符 FD 打开且指向一个终端则为真。
12 //[-n string] 如果 string长度非零,则为真 [ -n "$myvar" ]
13
14 if [ -t 1 ]; then
15 echo "ERROR: $TITLE
$1"
16 elif [ -n `which zenity` ]; then
17 zenity --error --title="$TITLE" --text="$1"
18 elif [ -n `which kdialog` ]; then
19 kdialog --error --title "$TITLE" "$1"
20 elif [ -n `which xmessage` ]; then
21 xmessage -center "ERROR: $TITLE: $1"
22 elif [ -n `which notify-send` ]; then
23 notify-send "ERROR: $TITLE: $1"
24 else
25 echo "ERROR: $TITLE
$1"
26 fi
27 }
28 UNAME=`which uname`
29 GREP=`which egrep`
30 GREP_OPTIONS=""
31 CUT=`which cut`
32 READLINK=`which readlink`
33 MKTEMP=`which mktemp`
34 RM=`which rm`
35 CAT=`which cat`
36 TR=`which tr`
37
38 #[ -o OPTIONNAME ] 如果 shell选项 “OPTIONNAME” 开启则为真。
39 #[ -z STRING ] “STRING” 的长度为零则为真。
40
41 if [ -z "$UNAME" -o -z "$GREP" -o -z "$CUT" -o -z "$MKTEMP" -o -z "$RM" -o -z "$CAT" -o -z "$TR" ]; then
42 message "Required tools are missing - check beginning of "$0" file for details."
43 exit 1
44 fi
45
46 OS_TYPE=`"$UNAME" -s`
47
48 # ---------------------------------------------------------------------
49 # Locate a JDK installation directory which will be used to run the IDE.
50 # Try (in order): STUDIO_JDK, JDK_HOME, JAVA_HOME, "java" in PATH.
51 # ---------------------------------------------------------------------
52
53 #[ -x FILE ] 如果 FILE 存在且是可执行的则为真。
54 #[ -a FILE ] 如果 FILE 存在则为真。
55
56 if [ -n "$STUDIO_JDK" -a -x "$STUDIO_JDK/bin/java" ]; then
57 JDK="$STUDIO_JDK"
58 elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
59 JDK="$JDK_HOME"
60 elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
61 JDK="$JAVA_HOME"
62 else
63 JAVA_BIN_PATH=`which java`
64 if [ -n "$JAVA_BIN_PATH" ]; then
65 if [ "$OS_TYPE" = "FreeBSD" ]; then
66 JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | "$GREP" '^JAVA_HOME' | "$CUT" -c11-`
67 if [ -x "$JAVA_LOCATION/bin/java" ]; then
68 JDK="$JAVA_LOCATION"
69 fi
70 elif [ "$OS_TYPE" = "SunOS" ]; then
71 JAVA_LOCATION="/usr/jdk/latest"
72 if [ -x "$JAVA_LOCATION/bin/java" ]; then
73 JDK="$JAVA_LOCATION"
74 fi
75 elif [ "$OS_TYPE" = "Darwin" ]; then
76 JAVA_LOCATION=`/usr/libexec/java_home`
77 if [ -x "$JAVA_LOCATION/bin/java" ]; then
78 JDK="$JAVA_LOCATION"
79 fi
80 fi
81
82 if [ -z "$JDK" -a -x "$READLINK" ]; then
83 JAVA_LOCATION=`"$READLINK" -f "$JAVA_BIN_PATH"`
84 case "$JAVA_LOCATION" in
85 */jre/bin/java)
86 JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname | xargs dirname` ;;
87 *)
88 JAVA_LOCATION=`echo "$JAVA_LOCATION" | xargs dirname | xargs dirname` ;;
89 esac
90 if [ -x "$JAVA_LOCATION/bin/java" ]; then
91 JDK="$JAVA_LOCATION"
92 fi
93 fi
94 fi
95 fi
96
97 #[ -z STRING ] “STRING” 的长度为零则为真。
98
99 if [ -z "$JDK" ]; then
100 message "No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation."
101 exit 1
102 fi
103
104 VERSION_LOG=`"$MKTEMP" -t java.version.log.XXXXXX`
105 "$JDK/bin/java" -version 2> "$VERSION_LOG"
106 "$GREP" 'OpenJDK' "$VERSION_LOG" > /dev/null
107 OPEN_JDK=$?
108 "$GREP" "64-Bit|x86_64" "$VERSION_LOG" > /dev/null
109 BITS=$?
110 "$RM" -f "$VERSION_LOG"
111 if [ $OPEN_JDK -eq 0 ]; then
112 echo "WARNING: You are launching the IDE using OpenJDK Java runtime."
113 echo
114 echo " ITS KNOWN TO HAVE PERFORMANCE AND GRAPHICS ISSUES!"
115 echo " SWITCH TO THE ORACLE(SUN) JDK BEFORE REPORTING PROBLEMS!"
116 echo
117 echo "NOTE: If you have both Oracle (Sun) JDK and OpenJDK installed"
118 echo " please validate either STUDIO_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation."
119 echo " See http://ow.ly/6TuKQ for more info on switching default JDK."
120 echo
121 echo "Press Enter to continue."
122 # ---------------------------------------------------------------------
123 # COMMENT LINE BELOW TO REMOVE PAUSE AFTER OPEN JDK WARNING
124 # ---------------------------------------------------------------------
125 read IGNORE
126 fi
127 if [ $BITS -eq 0 ]; then
128 BITS="64"
129 else
130 BITS=""
131 fi
132
133 # ---------------------------------------------------------------------
134 # Ensure IDE_HOME points to the directory where the IDE is installed.
135 # ---------------------------------------------------------------------
136
137 #[ -L FILE ] 如果 FILE 存在且是一个符号连接则为真。
138
139 SCRIPT_LOCATION=$0
140 if [ -x "$READLINK" ]; then
141 while [ -L "$SCRIPT_LOCATION" ]; do
142 SCRIPT_LOCATION=`"$READLINK" -e "$SCRIPT_LOCATION"`
143 done
144 fi
145
146 IDE_HOME=`dirname "$SCRIPT_LOCATION"`/..
147 IDE_BIN_HOME=`dirname "$SCRIPT_LOCATION"`
148
149 # ---------------------------------------------------------------------
150 # Collect JVM options and properties.
151 # ---------------------------------------------------------------------
152 if [ -n "$STUDIO_PROPERTIES" ]; then
153 IDE_PROPERTIES_PROPERTY="-Didea.properties.file="$STUDIO_PROPERTIES""
154 fi
155
156 MAIN_CLASS_NAME="$STUDIO_MAIN_CLASS_NAME"
157 if [ -z "$MAIN_CLASS_NAME" ]; then
158 MAIN_CLASS_NAME="com.intellij.idea.Main"
159 fi
160
161 VM_OPTIONS_FILE="$STUDIO_VM_OPTIONS"
162 if [ -z "$VM_OPTIONS_FILE" ]; then
163 VM_OPTIONS_FILE="$IDE_BIN_HOME/studio$BITS.vmoptions"
164 fi
165
166 if [ -r "$VM_OPTIONS_FILE" ]; then
167 VM_OPTIONS=`"$CAT" "$VM_OPTIONS_FILE" | "$GREP" -v "^#.*" | "$TR" '
' ' '`
168 VM_OPTIONS="$VM_OPTIONS -Djb.vmOptionsFile="$VM_OPTIONS_FILE""
169 fi
170
171 IS_EAP="true"
172 if [ "$IS_EAP" = "true" ]; then
173 OS_NAME=`echo $OS_TYPE | "$TR" '[:upper:]' '[:lower:]'`
174 AGENT_LIB="yjpagent-$OS_NAME$BITS"
175 if [ -r "$IDE_BIN_HOME/lib$AGENT_LIB.so" ]; then
176 AGENT="-agentlib:$AGENT_LIB=disablej2ee,disablealloc,delay=10000,sessionname=AndroidStudioPreview"
177 fi
178 fi
179
180 COMMON_JVM_ARGS=""-Xbootclasspath/a:$IDE_HOME/lib/boot.jar" -Didea.paths.selector=AndroidStudioPreview $IDE_PROPERTIES_PROPERTY"
181 IDE_JVM_ARGS="-Didea.platform.prefix=AndroidStudio"
182 ALL_JVM_ARGS="$VM_OPTIONS $COMMON_JVM_ARGS $IDE_JVM_ARGS $AGENT $REQUIRED_JVM_ARGS"
183
184 CLASSPATH="$IDE_HOME/lib/bootstrap.jar"
185 CLASSPATH="$CLASSPATH:$IDE_HOME/lib/extensions.jar"
186 CLASSPATH="$CLASSPATH:$IDE_HOME/lib/util.jar"
187 CLASSPATH="$CLASSPATH:$IDE_HOME/lib/jdom.jar"
188 CLASSPATH="$CLASSPATH:$IDE_HOME/lib/log4j.jar"
189 CLASSPATH="$CLASSPATH:$IDE_HOME/lib/trove4j.jar"
190 CLASSPATH="$CLASSPATH:$IDE_HOME/lib/jna.jar"
191 CLASSPATH="$CLASSPATH:$JDK/lib/tools.jar"
192 if [ -n "$STUDIO_CLASSPATH" ]; then
193 CLASSPATH="$CLASSPATH:$STUDIO_CLASSPATH"
194 fi
195 export CLASSPATH
196
197 LD_LIBRARY_PATH="$IDE_BIN_HOME:$LD_LIBRARY_PATH"
198 export LD_LIBRARY_PATH
199
200 # ---------------------------------------------------------------------
201 # Run the IDE.
202 # ---------------------------------------------------------------------
203 while true ; do
204 eval "$JDK/bin/java" $ALL_JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME $*
205 test $? -ne 88 && break
206 done
- Startup android-studio, JDK version is not qualified for studio
- Need to redownload the latest JDK
- reintall JDK, studio runs up.
- On my Linux, (for permission of network) failed to download gradle from http://services.gradle.org/distributions/gradle-1.6-bin.zip
- Create a folder and manualy copy the zip file to the folder as following png. After doing so, restart android studio to create a project,the studio will recognize that it has downloaded the gradle.
- The temporary folder is: /root/.gradle/wrapper/dists/gradle-1.6-bin/72srdo3a5eb3bic159kar72vok/