Android SDK
- Tools for Android application development
-
Downloadable from the Android developer site
- It can be downloaded standalone (to be used with the CLI)
- If we use Android Studio, on the first launch a wizard proposes to download the SDK
-
Main components of the Android SDK :
-
tools/: tools of the SDK
-
bin/
-
sdkmanager: package manager of the SDK
- To download tools for new versions of the API, related documentations
- To update existing components of the SDK (bug and security fixes, improvements...)
- avdmanager: tool to managed virtual machines (Android Virtual Devices): creation, modification, destruction
-
lint: tool to statically analyze the source code (to find problems, bugs...)
- Embedded in Android Studio
- screenshot2: to capture screenshots on the Android device
- uiautomatorviewer: tool to inspect the UI (to get the tree of components)
-
apkanalyzer: tool to extract data from an APK package (to fetch the manifest, the DEX bytecode, the list of resources...)
- Embedded in Android Studio (menu Build > Analyze APK)
- jobb: tool to create OBB extension packages (to gather additional resources for an application)
-
sdkmanager: package manager of the SDK
- emulator: x86 and ARM emulator to start Android Virtual Devices
-
monitor: live monitoring tool for Android applications
- supplies the used memory, the network trafic, the CPU load, can be used to inject fake calls and SMS...
- Embedded in Android Studio
-
bin/
- mkdsdcard: tool to create virtual SD cards for Android Virtual Devices
-
build-tools/: tools to compile projects (one directori for each API version)
- Header files
- Libraries
- Programs used for the compilation chain : aapt, aidl, zipalign, apksigner...
-
platform-tools: tools to communicate with an Android device
- adb (Android Debug Bridge): program to communicate between the dev computer and the Android device (to execute commands, fetch logs with logcat...)
- fastboot : program to flash Android devices (to change the booloader, the recovery partition, the modem firmware...)
- system-images/: system images to create virtual devices (for several API levels and architectures)
-
platforms/ : resources for each API version
- android.jar : file with all the signatures of classes amd methods of the Android API
-
docs/: documentation for the API (Javadoc)
- samples/: samples of code
- sources/: sources for each API level
-
tools/: tools of the SDK
☞ It is useful to add tools and platform-tools in the PATH environment variable
Android NDK
- Native Development Kit: to develop C/C++ libraries for Android applications
-
Useful for:
- new code tuning finely the memory (without using a garbage collector) and/or making intensive computations
- to port C/C++ libraries to Android
- Access to the NDK from the managed code (Java, Kotlin...) using JNI calls (Java Native Interface)
- Rust can also be used with the NDK
Integrated Development Environment (IDE)
-
Android Developer Tools (Eclipse)
- Project built with an Ant Script
- Obsolete
-
Android Studio (IntelliJ IDEA, Jetbrains)
- Project built with a Gradle script
- First choice for Android development (official support by Google)
- NBAndroid (NetBeans)
-
Xamarin (Microsoft Visual Studio)
- Only available for Windows
- Support for C#
SDK Manager
- Download (Windows, Linux, MacOS versions) : http://developer.android.com/sdk/
- Command: android sdk

Creating a virtual device
- One can use the graphical interface from Android Studio (Tools > AVD Manager)
- One can launch the standalone GUI: android avd
-
Or use the CLI:
- New SD card with a vfat FS: mksdcard -l carteSD 1024M carteSD.img
- New virtual device: android create avd -c carteSD.img -n myAVD --snapshot --target android-17
- Starting the virtual device: emulator @myAVD
- Useful options: -sdcard <file>, -memory <sizeInMBs>, -shell, -logcat <tags>, -tcpdump <file>
- For further information
Communication with ADB
Principles and startup
- ADB = Android Debug Bridge
-
Components of the ADB system:
- A client that runs on the development machine; it is used to send commands to the Android device
- A server running on the development machine: it is contacted by the client; it is a relay between the client and the Android device
- A daemon (adbd) running on the Android device that receives commands from the server and execute them
-
How to activate adb communication with an Android device ?
- Activate the developer mode by pressing several times on Build number from the About section of the settings app
- Activate USB debugging in the new Development menu that has appeared in the settings app
- Authorize the server from the computer used for development to contact adbd on the device (the computer is authentified with a cryptographic key)
☞ Some additional configuration may be required according to your OS. For example with Linux, if we use a physical Android device using an USB connection, this device must be registered using a udev rule to allow a normal user to access it.
Some useful commands
- adb push <source> <dest>: to copy a file from the local computer to the device
- adb pull <source> <dest>: to retrieve a file from the device to the local computer
- adb logcat <tags>: display the logs from logcat (tags can be used to filter the logs)
- adb shell: open an interactive shell on the Android device
- adb install <file>: install an application (APK package) on the Android device
- adb uninstall <package>: uninstall an application
- adb backup -f <file>: backup the user data
- adb restore <file>: restore the user data
- adb forward tcp:<local> tcp:<remote>: allow to access the port <local> of the Android device from the development computer using the port <remote> (thus we can run a server on the Android device and contact it from the computer)
- adb reverse tcp:<local> tcp:<remote>: allow to access the port <remote> of the developement computer from the Android device using the port <local> (thus a server can be run on the computer and the Android device can access it)
- Sous Linux des règles udev pour l'appareil peuvent être nécessaires (pour utiliser ADB sans être root), sous Windows l'installation de pilotes peut être requise
A glimpse of the standard Android API
android.* packages
- util: utility classes to analyze text, for logging, managing sparse arrays, caches...
- os : access to the IPC, to the energy manager, the clock, the environment variables, the vibrator...
- graphics : to handle images
- text: to display texts
- database: to manage databases using SQLite3
- content, provider: to manage content access across several applications
- view: legacy API for the graphical components
- widget: some useful views for GUIs
- app: base interfaces for the applications définition des interfaces de base des applications
- provider: to access common ContentProviders (CallLog, Contacts, MediaStore...)
- telephony, bluetooth, net: low-level access to communication features
- webkit: to display HTML content
- location: for geolocation (GPS, WiFi or cellular triangulation)
- media: recording and playback of AV data
- opengl: API for OpenGL rendering
- ...
Base classes to develop Android applications
The components of an Android applications must be implemented in classes that inherited from ome of this base classes:
- Activity: screen to interact with the user
- Fragment: chunk of screen that can be reused (deprecated with Jetpack Compose)
-
Service : a kind of daemon that does a task in the background without graphical feedback
- Can be called using RPC methods (from the same or another application)
- Can be used to execute tasks that are sent to it using an Intent (overriding the onStartCommand method)
-
ContentProvider: to expose a database of the application to another applications (examples: contacts, agenda...)
- Implementations of ContentProvider typically on the use of SQLite
- BroadcastReceiver: to react to events sent by the system or other applications (it is a kind of communication bus)