14. Appendices
The installation of [Android Studio], the emulator, and the setup of a phone are described in the chapter “Setting Up the Development Environment.” These appendices supplement that chapter.
14.1. Using Android Studio
- [File / Open]: open a project ([examples_kotlin], [rdvmedecins_kotlin]); [Gradle] “syncs” it (downloads the libraries);
- the [Run] button (or Shift-F10) installs and launches the app on the device selected in the toolbar; [Debug] (Shift-F9) launches it with the debugger (breakpoints, variables);
- [Apply Changes] replaces the code of a running application without restarting it, when possible;
- the annotation [@Preview] on a parameterless function [@Composable] displays it in the editor, without an emulator;
- the “Layout Inspector” ([Tools / Layout Inspector]) displays the component tree for the current screen and the number of recompositions for each component; “App Inspection” displays network requests ([OkHttp]) and databases;
- Pressing Alt-Enter on an error suggests corrections (add a [import]...); Ctrl-Alt-L reformats the file;
- Command line: [adb devices] (connected devices), [adb reverse tcp:8080 tcp:8080] (port 8080 on the device connected to the computer’s port), [adb install file.apk] (install an app), [adb logcat] (the phone log; in [Android Studio], the [Logcat] window), [emulator -list-avds], then [emulator -avd Pixel_8] (launch an emulator without [Android Studio]).
14.2. Screenshots from this document
The screenshots were generated automatically by INSTRUMENTED tests: [JUnit] tests that run ON the emulator—within the same process as the application—and control it via the [Compose] test library (find a component by its text, tap it, type into it, etc.). They are located in the [app/src/androidTest] folders of the two projects: [Captures.kt] (one test function per example) and [CaseStudyCaptures.kt] (a complete walkthrough of the application). An excerpt:
The scripts [tools/captures_examples.bat] and [tools/captures_case_study.bat] launch the emulator if necessary, compile and install the application and its tests, set up the emulator (language, status bar in “demo mode”), run the tests ([adb shell am instrument]), and then retrieve the images. The JSON server must be started, along with [CAPTCHA_TEST=test].
14.3. Installing Node.js
[Node.js] downloads to nodejs.org: select version LTS (long-term support). The [Windows] installer also installs [npm]. It is only required for the JSON server. Verify the installation in a console:
14.4. Installing MySQL with Laragon
The JSON server requires [MySQL] (or [MariaDB]). [Laragon] (laragon.org) installs a ready-to-use instance of [Windows] using the [HeidiSQL] administration tool. After installation:
- the “Start All” button launches the [MySQL] server on port 3306;
- the user [root] has no password: these are the default values from the server’s [.env.example] file;
- in [HeidiSQL] (the “Database” button), the File / Run SQL menu item runs the [database/dbrdvmedecins2.sql] script.
For [Linux] or [macOS], install [MySQL] or [MariaDB] using the system's package manager, and run the script using the command-line client: [mysql -u root -p < database/dbrdvmedecins2.sql].
14.5. Installing curl
[curl] is included with [Windows] versions 10 and 11, [macOS], and most distributions of [Linux]. Check its version:
The option [--json], used in this document, has been available since version 7.82 (2022). If you are using an older version, replace [--json @file] with [-H "Content-Type: application/json" -d @file], or install a recent version starting with curl.se.
In [PowerShell], you must enter [curl.exe], not [curl]: In [PowerShell], [curl] is an alias for another command ([Invoke-WebRequest]), which does not include the options from [curl]. The command prompt ([cmd]) does not have this issue.