635 views
*English version below* # Preparazione per i Corsi Android Prima di partecipare ai corsi, è fortemente consigliato prepararsi anticipatamente e eseguire i seguenti step, in modo da non incorrere in problemi durante il corso stesso. ## Installazione di Android Studio ### GNU/Linux Entrambi i metodi possono essere usati su tutte le distribuzioni GNU/Linux. Su Ubuntu è preferibile usare Snapcraft, su Fedora e Pop!_OS è preferibile usare Flathub. In tutti i casi, se nella vostra distribuzione trovate un "app store", troverete al suo interno anche Android Studio. #### Snapcraft (miglior metodo per Ubuntu) Installare Android Studio seguendo le istruzioni sul seguente sito: https://snapcraft.io/android-studio #### Flathub Installare Android Studio seguendo le istruzioni sul seguente sito: https://flathub.org/apps/details/com.google.AndroidStudio ### Windows Scaricare Android Studio dal sito ufficiale: https://developer.android.com/studio/ Eseguire l'installer lasciando le impostazioni predefinite. ### macOS Scaricare Android Studio dal sito ufficiale: https://developer.android.com/studio/ Montare il DMG aprendolo, quindi aprire l'icona dal desktop e trascinare l'icona di Android Studio dentro la cartella delle Applicazioni. ## Setup iniziale ### Tutte le piattaforme Aprire Android Studio. Procedere con la configurazione scegliendo il tema e lasciando le impostazioni predefinite. Verranno scaricati vari componenti. È possibile che appaia un errore relativo a un certo HAVX (su Windows). Non è un errore grave, ma se doveste usare l'emulatore, il vostro emulatore andrà a velocità molto scarse. Al termine, creare un nuovo progetto, selezionando il template "Basic Activity" e lasciando tutte le altre impostazioni ai valori predefiniti. Al termine della procedura guidata, attendere che il programma termini il setup iniziale del progetto. Il progetto può poi essere anche cancellato. È importante eseguire questo step in modo che Android Studio scarichi anticipatamente i propri componenti, evitando lunghi tempi di attesa durante il corso. ## Setup debug USB con ADB :::warning **Nota:** doveste avere problemi con la connessione di ADB con il vostro dispositivo, assicuratevi di eseguire anche le [istruzioni relative all'emulatore](#Setup-emulatore), in modo da evitare brutte sorprese durante il corso. ::: Verificate su Internet come attivare il debug USB nel vostro dispositivo. Una volta fatto, seguite le seguenti istruzioni per verificare che funzioni tutto. In caso di problemi, leggere le informazioni nella pagina https://developer.android.com/studio/run/device ### Ubuntu / Pop!_OS e derivate Installare `adb` ```bash sudo apt install adb ``` Aggiungere il proprio utente al gruppo `plugdev` per avere i permessi per accedere ai dispositivi USB Android: ```bash sudo usermod -aG plugdev $USER ``` Terminare la propria sessione e fare nuovamente il login. In alternativa, riavviare. Eseguire il comando `adb devices` nel terminale. Dovrebbe elencare il numero di serie del vostro dispositivo, seguito da `device`. ### Altre distribuzioni GNU/Linux Verificare nella documentazione della propria distribuzione come installare ADB e come darsi i permessi per accedere al dispositivo. Per esempio, [Arch Linux](https://wiki.archlinux.org/index.php/Android_Debug_Bridge). ### Windows Aprire il prompt dei comandi, oppure il terminale integrato in Android Studio. Digitare/incollare: ```bat cd %localappdata%\Android\Sdk\platform-tools ``` Dopodiché eseguire il comando `adb devices`. Dovrebbe elencare il numero di serie del vostro dispositivo, seguito da `device`. In caso il dispositivo non venga riconosciuto, potrebbe essere necessario installare i driver. Seguire le istruzioni indicate nella seguente pagina: https://developer.android.com/studio/run/oem-usb.html ### macOS Eseguire nel terminale: ```bash touch ~/.bash_profile; nano ~/.bash_profile ``` Oppure, se state usando `zsh`: ```bash touch ~/.zshrc; nano ~/.zshrc ``` Spostarsi alla fine del file e incollare: ```bash export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools ``` Salvare con `Ctrl`+`X`, seguito da `y` per confermare. Chiudere e riaprire il terminale. Eseguire il comando `adb devices`. Dovrebbe elencare il numero di serie del vostro dispositivo, seguito da `device`. In caso il dispositivo non venga riconosciuto, potrebbe essere necessario installare i driver. Seguire le istruzioni indicate nella seguente pagina: https://developer.android.com/studio/run/oem-usb.html#Drivers ## Setup emulatore :::success **Nota:** Non è necessario l'emulatore se siete riusciti a collegarvi con ADB al telefono. ::: 1. Da Tools selezionare AVD Manager (Android Virtual Device) 2. Cliccare "Create new device" 3. Selezionare un modello di **telefono** a piacere - La scelta è puramente estetica - Non è necessario selezionare un dispositivo che supporti i Google Play Services per i fini del corso 4. Nella pagina successiva, selezionare Download per l'immagine di Android 10 (Q) **senza** Google APIs dalla pagina *x86 Images* - Le Google APIs non ci servono e sono inutilmente pesanti - Va bene sia x86 che x86_64, tirate una moneta 5. A download terminato, procedere alla pagina successiva 6. Lasciare le impostazioni di default nella configurazione Sarà ora possibile avviare il dispositivo virtuale. Una volta avviato il dispositivo virtuale, seguite le istruzioni del punto precedente per verificare la connessione ADB con l'emulatore. ---- # Android courses preparation Before taking part to the courses, we strongly recommend to prepare in advance and follow the steps below, to be able to follow without interruptions during the talks. ## Install Android Studio ### GNU/Linux Both methods can be used across all GNU/Linux distributions. As an installation source, on Ubuntu we recommand [Snapcraft](https://snapcraft.io/android-studio), on Fedora and Pop!_OS [Flathub](https://flathub.org/apps/details/com.google.AndroidStudio) is suggested. #### Snapcraft Follow the instructions on https://snapcraft.io/android-studio #### Flathub Follow the instructions on ttps://flathub.org/apps/details/com.google.AndroidStudio ### Windows Download Android Studio from the official website: https://developer.android.com/studio/ ### macOS Download Android Studio from the official website: https://developer.android.com/studio/ Mount the DMG by opening it, then open the Desktop icon and drag the Android Studio icon insde the Applications folder. ## Initial Setup ### All platforms Launch Android Studio. Walk through the configuration wizard, choosing the theme and leaving the defaults settings. Several components will be downloaded. On Windows, an error on a HAVX may pop up: it's not a big deal, but if you are willing to use the emulator, then it will run very slow. After the wizard has run, create a new project, selecting te template "Basic Activity" and leaving all other settings to defaults. When the guided project setup closes, wait a minute or two for the project to be acyually fulli initialized. The previous step is a workaround to let Android Studio download other components that otherwise it will request whan starting a new project: you may as well delete the project you just created for this purpose. ## Setup ADB using USB Debug :::warinig **Note**: if you experience issues with the ADB setup, be sure to follow also the [emulator setup instructios](#Emulator-setup), to avoid wasting time on it during talks. ::: Search on the Internet how to enable USB debugging on your device. Then, go through the following steps to check that everything works. In case of problems, read the instructions about running your Android Studiuo project on a physical Android device at the link https://developer.android.com/studio/run/device ### Ubuntu / Pop!_OS and derivatives Install `adb` ```bash sudo apt install adb ``` Add your user to the group `plugdev` to access USB Android devices ```bash sudo usermod -aG plugdev $USER ``` Terminate the user session and log back in. Run the command `adb devices` into a terminal emulator: if your Android device is connected to your PC, you should see its serial number pop up, followed by "device". ### Other GNU/Linux distro Check inside your distro documentation or wiki how to install ADB and give permissions to it; for example, [Arch Linux](https://wiki.archlinux.org/index.php/Android_Debug_Bridge). ### Windows Open the command prompt, or the Android Studio terminal. Paste the following comand: ```bat cd %localappdata%\Android\Sdk\platform-tools ``` Then run the command `adb devices`. You should see your device's serial number pop up, ollowed by "device". If your device is not recognized, you may need to install the ADB drivers: follow the instructions at the link https://developer.android.com/studio/run/oem-usb.html#Drivers ### macOS Run inside the Terminal app: ```bash touch ~/.bash_profile; nano ~/.bash_profile ``` If your using `zsh` and not `bash`, run instead: ```bash touch ~/.zshrc; nano ~/.zshrc ``` go to the end of the file, and paste the following lines: ```bash export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-tools ``` Save with `Ctrl`+`X`, followed by `Y` to confirm. Close and reopen the Terminal app Run the command `adb devices`. You should see your device's serial number pop up, ollowed by "device". If your device is not recognized, you may need to install the ADB drivers: follow the instructions at the link https://developer.android.com/studio/run/oem-usb.html#Drivers ## Setuo emulator :::success **Note**: If you successfully connected to your device with ADB, you can skip the emulator setup ::: 1. From Tools menu, select AVD Manager (Android Virtual Device) 2. click "Create new device" 3. select a model of virtual device - just a cosmetic decision - you may not select a device that supports the Google Play Services (for the purpose of this course) 4. from the following page, select "Download" for the Android 10 (Q) image **without** Google APIs from the list "x86 Images" - the Google APIs are a huge download and also we will not use it - x86 and x86_64 are worth the same, flip a coin if in doubt 5. when the download finishes, go to the next page 6. leva all settings to default and close the wizard Now you should be able to run the AVD. When you launch the virtual device for the first time, be sure to check if the ADB connection works with it, by following the stsps from the previous section.