public
Last active

Android SDK + NDK + Eclipse and ADB Installer

  • Download Gist
installer.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
#!/bin/bash
#
#This script is designed to install the Android SDK, NDK, and Eclipse in Linux Mint 11 and make it easier for people that want to develop for Android using Linux.
#Script written by @ArchDukeDoug with special thanks to @BoneyNicole, @tabbwabb, and @animedbz16 for putting up with me and proofreading and/or testing the script.
#I can be reached at dougw@uab.edu, twitter, or linuxrandomly.blogspot.com
#Script version: 1.0.5
#Changelog: 1.0.5 - Fixed the Android SDK search parameters to fit the new naming scheme on http://developer.android.com/sdk
i=$(cat /proc/$PPID/cmdline)
if [[ $UID != 0 ]]; then
echo "Please type sudo $0 $*to use this."
exit 1
fi
 
apt-get update
 
#Download and install the Android SDK
if [ ! -d "/usr/local/android-sdk" ]; then
for a in $( wget -qO- http://developer.android.com/sdk/index.html | egrep -o "http://dl.google.com[^\"']*linux.tgz" ); do
wget $a && tar --wildcards --no-anchored -xvzf android-sdk_*-linux.tgz; mv android-sdk-linux /usr/local/android-sdk; chmod 777 -R /usr/local/android-sdk; rm android-sdk_*-linux.tgz;
done
else
echo "Android SDK already installed to /usr/local/android-sdk. Skipping."
fi
 
#Download and install the Android NDK
if [ ! -d "/usr/local/android-ndk" ]; then
for b in $( wget -qO- http://developer.android.com/sdk/ndk/index.html | egrep -o "http://dl.google.com[^\"']*linux-x86.tar.bz2"
); do wget $b && tar --wildcards --no-anchored -xjvf android-ndk-*-linux-x86.tar.bz2; mv android-ndk-*/ /usr/local/android-ndk; chmod 777 -R /usr/local/android-ndk; rm android-ndk-*-linux-x86.tar.bz2;
done
else
echo "Android NDK already installed to /usr/local/android-ndk. Skipping."
fi
 
d=ia32-libs
 
#Determine if there is a 32 or 64-bit operating system installed and then install ia32-libs if necessary.
 
if [[ `getconf LONG_BIT` = "64" ]];
 
then
echo "64-bit operating system detected. Checking to see if $d is installed."
 
if [[ $(dpkg-query -f'${Status}' --show $d 2>/dev/null) = *\ installed ]]; then
echo "$d already installed."
else
echo "Installing now..."
apt-get --force-yes -y install $d
fi
else
echo "32-bit operating system detected. Skipping."
fi
 
#Check if Eclipse is installed
c=eclipse
echo "checking if $c is installed" 2>&1
if [[ $(dpkg-query -f'${Status}' --show $c 2>/dev/null) = *\ installed ]];
then
echo "$c already installed. Skipping."
else
echo "$c was not found, installing..." 2>&1
apt-get --force-yes -y install $c 2>/dev/null
fi
 
#Check if the ADB environment is set up.
 
if grep -q /usr/local/android-sdk/platform-tools /etc/bash.bashrc;
then
echo "ADB environment already set up"
else
echo "export PATH=$PATH:/usr/local/android-sdk/platform-tools" >> /etc/bash.bashrc
fi
 
#Check if the ddms symlink is set up.
 
if [ -f /bin/ddms ]
then
rm /bin/ddms; ln -s /usr/local/android-sdk/tools/ddms /bin/ddms
else
ln -s /usr/local/android-sdk/tools/ddms /bin/ddms
fi
 
#Create etc/udev/rules.d/99-android.rules file
 
touch -f 99-android.rules
echo "#Acer" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0502", MODE="0666"" >> 99-android.rules
echo "#ASUS" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0b05", MODE="0666"" >> 99-android.rules
echo "#Dell" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="413c", MODE="0666"" >> 99-android.rules
echo "#Foxconn" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0489", MODE="0666"" >> 99-android.rules
echo "#Garmin-Asus" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="091E", MODE="0666"" >> 99-android.rules
echo "#Google" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"" >> 99-android.rules
echo "#HTC" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"" >> 99-android.rules
echo "#Huawei" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", MODE="0666"" >> 99-android.rules
echo "#K-Touch" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="24e3", MODE="0666"" >> 99-android.rules
echo "#KT Tech" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="2116", MODE="0666"" >> 99-android.rules
echo "#Kyocera" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0482", MODE="0666"" >> 99-android.rules
echo "#Lenevo" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="17EF", MODE="0666"" >> 99-android.rules
echo "#LG" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", MODE="0666"" >> 99-android.rules
echo "#Motorola" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"" >> 99-android.rules
echo "#NEC" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0409", MODE="0666"" >> 99-android.rules
echo "#Nook" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="2080", MODE="0666"" >> 99-android.rules
echo "#Nvidia" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0955", MODE="0666"" >> 99-android.rules
echo "#OTGV" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="2257", MODE="0666"" >> 99-android.rules
echo "#Pantech" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="10A9", MODE="0666"" >> 99-android.rules
echo "#Philips" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0471", MODE="0666"" >> 99-android.rules
echo "#PMC-Sierra" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="04da", MODE="0666"" >> 99-android.rules
echo "#Qualcomm" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="05c6", MODE="0666"" >> 99-android.rules
echo "#SK Telesys" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="1f53", MODE="0666"" >> 99-android.rules
echo "#Samsung" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"" >> 99-android.rules
echo "#Sharp" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="04dd", MODE="0666"" >> 99-android.rules
echo "#Sony Ericsson" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0fce", MODE="0666"" >> 99-android.rules
echo "#Toshiba" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="0930", MODE="0666"" >> 99-android.rules
echo "#ZTE" >> 99-android.rules
echo "SUBSYSTEM=="usb", SYSFS{idVendor}=="19D2", MODE="0666"" >> 99-android.rules
mv -f 99-android.rules /etc/udev/rules.d/
chmod a+r /etc/udev/rules.d/99-android.rules
 
#Check if ADB is already installed
if [ ! -f "/usr/local/android-sdk/platform-tools/adb" ];
then
nohup /usr/local/android-sdk/tools/android update sdk > /dev/null 2>&1 &
zenity --info --text="Please accept the licensing agreement for Android SDK Platform-tools to install the Android Debug Bridge."
else
echo "Android Debug Bridge already detected."
fi
exit 0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.