1. Instalare Android Studio

  • instrucțiuni instalare în primul laborator

2. ADB

  • comanda adb se regăsește acolo unde ați instalat SDK-ul, de exemplu la: /opt/Android/SDK/platform-tools/adb
  • trebuie activat modul developer telefon sau emulator
  • avem nevoie de opțiunea "USB debugging"
  • la comanda adb shell pe laptopul de dezvoltare, telefonul va afișa un prompt care cere permisiunea de conectare prin USB
  • adb funcționează peste cablul USB, sau peste WiFi dacă telefonul și laptopul sunt în aceeași rețea WiFi. Se recomandă setyupul inițial folosind cablul USB

2.1 USB setup

  • Dacă laptopul Linux nu vede telefonul la comanda adb devices

  • udev rules

2.2 adb over wifi

using Android Studio menus
  • Din meniul de device-uri, se selectează "Pair Devices Using WiFi"
using wireless only
  1. phone and laptop must be on the same WiFi network, for example UPB-guest
  2. phone: in developer options/Quick settings developer tiles activate Wireless debugging
  3. phone: in Settings/about phone/Device identtifiers find IP address
  4. laptop: adb mdns check should answer mdns daemon version [Openscreen discovery x.y.z]
  5. phone: Hold the tile to enter the menu and choose 'Pair device with pairing code'. IP:port is shown
  6. laptop: adb mdns services should see the IP:port exposed by the phone, for the service _adb-tls-connect._tcp
  7. laptop: adb pair IP:port, enter the code displayed by the phone
  8. laptop: adb devices now shows a device with a long name ending in '..._adb-tls-connect._tcp'
  9. laptop: adb shell should give the prompt on the phone
  • alternatively, for point 7 generate a QR code on the terminal and pair from the tile
using USB cable I
  • adb over wifi

  • Connect the device and the computer to the same Wi-Fi network

  • Plug the device to the computer with a USB cable to configure the connection

  • On the computer command line type: adb tcpip 5555

  • On the computer command line type: adb shell ip addr show wlan0 and copy the IP address after the "inet" until the "/". You can also go inside the Settings of the device to retrieve the IP address in Settings → About → Status.

  • On the computer command line type: adb connect ip-address-of-device:5555

  • You can disconnect the USB cable from the device and check with adb devices that the device is still detected.

3. Imagine AVD cu root și GMS

Pașii depind de arhitectura procesorului calculatorului pe care rulați emulatorul. Emulatorul Android poate rula doar imagini de aceeași arhitectură cu procesorul gazdă:

  • x86_64 - calculatoarele din laborator, laptopuri cu Linux/Windows, Mac cu procesor Intel
  • arm64 - Mac cu procesor Apple Silicon (M1, M2, M3, M4...) - verificați în meniul Apple → About This Mac (Chip: Apple M...) sau cu uname -m (afișează arm64)

SDK-ul Android se găsește implicit la: Linux (laborator) /opt/Android/SDK, macOS ~/Library/Android/sdk, Windows %LOCALAPPDATA%\Android\Sdk. Calea exactă apare în Android Studio la Settings → Languages & Frameworks → Android SDK.

  • din Tools/SDK Manager/SDK platforms se adauga 'Android 15.0 ("VanillaIceCream")' API 35 Revison 2

  • Unzip lineage-gms-root.zip at location where studio keeps its images, for example
    /opt/Android/SDK/system-images/android-35/lineage/x86_64

  • Create virtual device

Android Studio -> Device Manager -> +(Add New Device, small phone) -> API 35/Services = Show All -> Under System image it shows “LineageOS” but it doesn’t have the download icon ; under API it says ‘35’

  • Give it a unique name, say Lineageos-EIM1

  • Additional settings - choose low specs: 2 CPU, 512M of RAM

  • Start => Setup – use 3 button navigation

  • In Android, go to Settings/About Device/Build number – click it 5 times to become a developer

  • Settings/search for root to find the option for rooted debugging; enable root

  • From developement machine

adb root 
adb shell
  • After first boot and setup, user data and apps are stored in $HOME/.android/avd/EIM_lineageos_1.avd/
  • create a second machine if needed
  • din Tools/SDK Manager/SDK Platforms se bifează Show Package Details, iar la 'Android 15.0 ("VanillaIceCream")' API 35 se adaugă Google APIs ARM 64 v8a System Image (atenție: nu "Google Play ARM 64 v8a System Image", aceasta nu permite root)

  • alternativ, din linia de comandă:

~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager "system-images;android-35;google_apis;arm64-v8a"
  • Create virtual device

Android Studio -> Device Manager -> +(Add New Device, small phone) -> API 35/Services = Show All -> System image: Google APIs ARM 64 v8a

  • Give it a unique name, say EIM-API35-arm64

  • Additional settings - 2 CPU, 2048M of RAM (recomandat pentru API 35)

  • Start => Setup – use 3 button navigation

  • Root-ul este disponibil direct, fără setări suplimentare în Android. From developement machine

adb root 
adb shell id      # uid=0(root)
adb shell
  • After first boot and setup, user data and apps are stored in $HOME/.android/avd/EIM-API35-arm64.avd/
  • create a second machine if needed

Rulare laboratoare

Laboratortelefon realemulator AVD
1 DicerollerYY
2 ActivitățiYY
3 GUIYY
4 IntențiiYY
5 ServiciiYY
6 SocketsYY
7 BluetoothYY
8 HTTPYY
9 Descoperire ServiciiYN
10 SIP & VoIPYY
11 LocalizareYY