Approche CLI
Testé sur Ubuntu 15.10, Android 22.
Un périphérique:
- activer le mode développeur et le débogage USB: lien
- relier le périphérique à l’ordinateur avec le câble USB
Alors:
sudo apt-get install ant gradle openjdk-7-jdk
cd
# Get device permissions.
# MANUAL find vendor ID on this table: http://developer.android.com/tools/device.html#VendorIds
# http://stackoverflow.com/a/5510745/895245
VENDOR_ID='054c'
UDEV_PATH='/etc/udev/rules.d/51-android.rules'
echo 'SUBSYSTEM=="usb", ATTR'"$VENDOR_ID"'=="0bb4", MODE="0666", GROUP="plugdev"' | sudo tee "$UDEV_PATH"
sudo chmod a+r "$UDEV_PATH"
sudo /etc/init.d/udev restart
wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar -xvf android-sdk_r24.4.1-linux.tgz
# MANUAL run the ./tools/android GUI and install the SDK versions you need
# Better: just download EVERYTHING to save you annoyances later on.
# Yes, it takes a ton of space (50Gib+).
# http://stackoverflow.com/questions/17963508/how-to-install-android-sdk-build-tools-on-the-command-line
# The automated command line should look something like:
#API=22
#N="$(android list sdk --all |& grep 'SDK Platform Android' | grep "API $API" | cut -d- -f1)"
#android update sdk -u -a -t $N
# Studio
wget https://dl.google.com/dl/android/studio/ide-zips/1.5.1.0/android-studio-ide-141.2456560-linux.zip
unzip android-studio-ide-141.2456560-linux.zip
cd android-studio/bin
./studio.sh
# NDK
wget http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin
chmod a+x android-ndk-r10e-linux-x86_64.bin
./android-ndk-r10e-linux-x86_64.bin
mv android-ndk-r10e android-ndk
Ajoutez à votre ~/.profile
: TODO: lesquels sont réellement nécessaires?
export ANDROID_SDK="$HOME/android-sdk"
# Present on the default build.xml generated by "android create project [...] in Android 22.
export ANDROID_HOME="$ANDROID_SDK"
export ANDROID_NDK="$HOME/android-ndk"s
export ANDROID_NDK_ROOT="$ANDROID_NDK"
# Used by https://github.com/googlesamples/android-ndk/tree/3cd41e1f5280443665ca98463c7a76e80bf0b96c/native-codec
export ANDROID_NDK_HOME="$ANDROID_NDK"
export ANDROID_ABI='armeabi-v7a'
export ANDROID_JAVA_HOME="$JAVA_HOME"
export ANDROID_STUDIO="$HOME/android-studio/"
export PATH="$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools:${ANDROID_STUDIO}/bin:${ANDROID_NDK}:${PATH}"
Déconnexion et connexion. Vous pourriez avoir besoin de:
sudo "$(which adb)" kill-server
sudo "$(which adb)" start-server
Testez l’installation
Mettez la main sur un projet minimal comme celui-ci ou regardez sous $ANDROID_SDK/samples/
.
S'il s'agit d'un projet Ant (contient un fichier build.xml
), exécutez:
ant debug
ant installd
Si c'est un projet Gradle (contient un fichier gradlew
), exécutez:
./gradlew assembleDebug
./gradlew installDebug
L'application doit être installée sur votre appareil.
Studio (successeur ADT) peut être lancé avec:
studio.sh
Les exemples NDK peuvent être trouvés sous $ANDROID_NDK/samples
et vous pouvez les construire et les installer avec:
ndk-build
# Create build.xml, as per: http://stackoverflow.com/questions/5572304/how-to-build-the-android-sample-projectsusing-ant-build-xml-does-not-exist
android update project -p . -t android-22
ant clean
ant debug
ant installd
État des paquets Debian officiels
Il n’existe actuellement aucun paquet Debian officiel.
Mais un projet Google Summer of Code 2015 tente de résoudre ce problème: lien