Exercise 1 - Download and install Android studio
Exercise 1 - Download and install Android studio
1
- The Device Manager dialog opens. If you created a virtual device previously, it's
listed in this dialog.
- Click Create Virtual Device, the Virtual Device Configuration dialog appears.
The dialog shows a list of pre-configured devices, organized by category, from
which you can choose. For each device, the table provides a column for its display
size (in inches), screen resolution (in pixels), and pixel density (number of pixels
per inch).
3
- In the AVD Name field, enter a name for your AVD or use the default. Leave the
rest of the fields unchanged. Click Finish. This action returns to the Android
Virtual Device Manager pane.
- Click .
- The virtual device starts just like a physical device. Expect this to take a while—
potentially several minutes—for the emulator to start for the first time. The virtual
device should open beside the code editor.
4
4.Run your app on the Android device
4.1.Enable USB debugging
To let Android Studio communicate with your Android device, you must enable USB
debugging in the Developer options settings of the device.
To show developer options and enable USB debugging:
- On your Android device, tap Settings > About phone.
- Tap Build number seven times.
- If prompted, enter your device password or pin. You know you succeeded when you
see a You are now a developer! message.
- Return to Settings and then tap System > Developer options. If you don't
see Developer options, tap Advanced options.
5
- Tap Developer options and then tap the USB debugging toggle to turn it on.
6
4.2.Run your app on the Android device with a cable
- Connect your Android device to your computer with a USB cable. A dialog should
appear on your device, which asks you to allow USB debugging.
- Select the Always allow from this computer checkbox and then tap OK.
- In Android Studio on your computer, make sure your device is selected in the
dropdown. Click .
- Select your device and then click OK. Android Studio installs the app on your
device and runs it. If your device runs an Android platform that isn't installed in
Android Studio and you see a message that asks whether you want to install the
needed platform, click Install > Continue > Finish. Android Studio installs the app
on your device and runs it.
4.3.Run your app on the Android device with Wi-Fi
If you don't have a cable, you can also connect and run your app on your device with Wi-
Fi.
- Ensure that your computer and device are connected to the same wireless network.
- Ensure that your device runs Android 11 or higher. For more information, see Check
& update your Android version.
7
- Ensure that your computer has the latest version of Android Studio. To download
it, see Android Studio.
- Ensure that your computer has the latest version of the SDK Platform Tools.
Pair your device:
- In Android Studio, select Pair Devices Using Wi-Fi from the run configurations
drop-down menu. The Pair devices over Wi-Fi dialog opens.
8
- If you want to pair your device with a QR code, select Pair device with QR
code and then scan the QR code on your computer. Alternatively, if you want to
pair your device with a pairing code, select Pair device with pairing code and then
enter the 6-digit code.
- Click run and you can deploy your app to your device.
5.Android studio
5.1.Project structure
Each project in Android Studio contains one or more modules with source code files and
resource files. Types of modules include:
- Android app modules
- Library modules
- Google App Engine modules
9
All the build files are visible at the top level under Gradle Scripts and each app module
contains the following folders:
- manifests: Contains the AndroidManifest.xml file.
- java: Contains the Java source code files, including JUnit test code.
- res: Contains all non-code resources, such as XML layouts, UI strings, and bitmap
images.
5.2.The user interface
The Android Studio main window is made up of several logical areas:.
1. The toolbar lets you carry out a wide range of actions, including running your app and
launching Android tools.
10
2. The navigation bar helps you navigate through your project and open files for editing.
It provides a more compact view of the structure visible in the Project window.
3. The editor window is where you create and modify code. Depending on the current
file type, the editor can change. For example, when viewing a layout file, the editor
displays the Layout Editor.
4. The tool window bar runs around the outside of the IDE window and contains the
buttons that allow you to expand or collapse individual tool windows.
5. The tool windows give you access to specific tasks like project management, search,
version control, and more. You can expand them and collapse them.
6. The status bar displays the status of your project and the IDE itself, as well as any
warnings or messages.
5.3.Gradle build system
Android Studio uses Gradle as the foundation of the build system, with more Android-
specific capabilities provided by the Android plugin for Gradle. This build system runs as
an integrated tool from the Android Studio menu, and independently from the command
line. You can use the features of the build system to do the following:
- Customize, configure, and extend the build process.
- Create multiple APKs for your app, with different features using the same project
and modules.
- Reuse code and resources across sourcesets.
By employing the flexibility of Gradle, you can achieve all of this without modifying your
app's core source files. Android Studio build files are named build.gradle. They are plain
text files that use Groovy syntax to configure the build with elements provided by the
Android plugin for Gradle. Each project has one top-level build file for the entire project
and separate module-level build files for each module. When you import an existing
project, Android Studio automatically generates the necessary build files.
References:
https://developer.android.com/codelabs/basic-android-kotlin-compose-install-android-
studio#0
https://developer.android.com/codelabs/basic-android-kotlin-compose-connect-
device?continue=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.android.com%2Fcourses%2Fpathways%2
Fandroid-basics-compose-unit-1-pathway-2%23codelab-
https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-
compose-connect-device#0
https://developer.android.com/studio/intro
11