xref: /expo/docs/pages/build-reference/apk.mdx (revision a16ac082)
1---
2title: Build APKs for Android Emulators and devices
3description: Learn how to configure and install an .apk for Android Emulators and devices when using EAS Build.
4---
5
6import { Terminal } from '~/ui/components/Snippet';
7import ImageSpotlight from '~/components/plugins/ImageSpotlight';
8
9The default file format used when building Android apps with EAS Build is an [Android App Bundle](https://developer.android.com/platform/technology/app-bundle) (AAB/**.aab**). This format is optimized for distribution to the Google Play Store. However, AABs can't be installed directly on your device. To install a build directly to your Android device or emulator, you need to build an [Android Package](https://en.wikipedia.org/wiki/Android_application_package) (APK/**.apk**) instead.
10
11## Configuring a profile to build APKs
12
13To generate an **.apk**, modify the [**eas.json**](/build/eas-json) by adding one of the following properties in a build profile:
14
15- `developmentClient` to `true` (**default**)
16- `android.buildType` to `apk`
17- `android.gradleCommand` to `:app:assembleRelease`, `:app:assembleDebug` or any other gradle command that produces **.apk**
18
19```json eas.json
20{
21  "build": {
22    "preview": {
23      "android": {
24        "buildType": "apk"
25      }
26    },
27    "preview2": {
28      "android": {
29        "gradleCommand": ":app:assembleRelease"
30      }
31    },
32    "preview3": {
33      "developmentClient": true
34    },
35    "production": {}
36  }
37}
38```
39
40Now you can run your build with the following command:
41
42<Terminal cmd={['$ eas build -p android --profile preview']} />
43
44Remember that you can name the profile whatever you like. We named the profile `preview`. However, you can call it `local`, `emulator`, or whatever makes the most sense for you.
45
46## Installing your build
47
48### Emulator (virtual device)
49
50> If you haven't installed or run an Android Emulator before, follow the [Android Studio emulator guide](/workflow/android-studio-emulator) before proceeding.
51
52Once your build is completed, the CLI will prompt you to automatically download and install it on the Android Emulator. When prompted, press <kbd>Y</kbd> to directly install it on the emulator.
53
54In case you have multiple builds, you can also run the `eas build:run` command at any time to download a specific build and automatically install it on the Android Emulator:
55
56<Terminal cmd={['$ eas build:run -p android']} />
57
58The command also shows a list of available builds of your project. You can select the build to install on the emulator from this list. Each build in the list has a build ID, the time elapsed since the build creation, the build number, the version number, and the git commit information. The list also displays invalid builds if a project has any.
59
60For example, the image below lists the build of a project:
61
62<ImageSpotlight
63  alt="Running eas build:run command shows a list of available builds in a project."
64  src="/static/images/eas-build/eas-build-run-on-android.png"
65/>
66
67When the build's installation is complete, it will appear on the home screen. If it's a development build, open a terminal window and start the development server by running the command `npx expo start`. For SDK 48 and lower, use the `--dev-client` flag with the command.
68
69#### Running the latest build
70
71Pass the `--latest` flag to the `eas build:run` command to download and install the latest build on the Android Emulator:
72
73<Terminal cmd={['$ eas build:run -p android --latest']} />
74
75### Physical device
76
77#### Download directly to the device
78
79- Once your build is completed, copy the URL to the APK from the build details page or the link provided when `eas build` is done.
80- Send that URL to your device. Maybe by email? Up to you.
81- Open the URL on your device, install the APK and run it.
82
83#### Install with `adb`
84
85- [Install adb](https://developer.android.com/studio/command-line/adb) if you don't have it installed already.
86- Connect your device to your computer and [enable adb debugging on your device](https://developer.android.com/studio/command-line/adb#Enabling) if you haven't already.
87- Once your build is completed, download the APK from the build details page or the link provided when `eas build` is done.
88- Run `adb install path/to/the/file.apk`.
89- Run the app on your device.
90