Skip to content

Commit e303eb8

Browse files
authored
docs: CLI - portals serve android (#268)
1 parent 3c7ea0b commit e303eb8

File tree

4 files changed

+93
-5
lines changed

4 files changed

+93
-5
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: CLI Command - serve android
3+
sidebar_label: serve android
4+
---
5+
6+
The `portals serve android` command is a tool for web developers to debug and test their
7+
web code in different Portal configurations on an emulator or a device without having
8+
to go through the build process of a native application or even have access to its
9+
source code. The command allows web developers to run their web code from their local
10+
dev server and see the changes on the fly.
11+
12+
:::note
13+
14+
The serve command requires Ionic Portals 0.9.0 or higher and requires that the portal
15+
has [`devMode`](https://ionic.io/docs/portals-android-api-ref/-ionic-portals/io.ionic.portals/-portal/index.html#-813353364%2FProperties%2F-149544105) set to `true`.
16+
17+
:::
18+
19+
### Requirements
20+
21+
The following environment variables must be set in order for the `portals serve android` command to function correctly:
22+
23+
- Set the `$ANDROID_HOME` variable to the path of the Android SDK installation directory.
24+
- Set the `$JAVA_HOME` variable to the path of the Java SDK installation directory.
25+
26+
### Usage
27+
```bash
28+
portals serve android \
29+
--application /path/to/your/android-app.apk \
30+
--dev-server http://10.0.2.2:8100
31+
```
32+
This command will present an interactive list of eligible destinations since no specific device details were provided. When selected, the command will launch the Android app to the selected device and will override all portals with the content served from the development server URL by default. If a capacitor.config.{json, ts, js} file is located in the current working directory, it will use that, otherwise it will fallback to any configuration potentially shipped in the application.
33+
34+
:::note
35+
36+
If the local dev server is set to `localhost` the CLI will attempt to help you by correcting this host to `10.0.2.2` for running in an emulator. Android emulators are unable to reach the host machine through `localhost` as this is reserved as the loopback address for reaching the emulator itself. Make sure to set the dev server address correctly if you need to reach it via your local network from a real Android device.
37+
38+
:::
39+
40+
### Examples
41+
42+
#### Specify capacitor configuration file
43+
44+
```bash
45+
portals serve android \
46+
--application /path/to/your/android-app.apk \
47+
--dev-server http://10.0.2.2:8100 \
48+
--capacitor-config /path/to/your/capacitor.config.ts
49+
```
50+
51+
#### Specify device details
52+
53+
If you know the specific device ID of the emulator or device you want to target, you can use the `--device-id` flag:
54+
55+
```bash
56+
portals serve android \
57+
--application /path/to/your/android-app.apk \
58+
--dev-server http://10.0.2.2:8100 \
59+
--device-id "emulator-5554"
60+
```
61+
62+
:::note
63+
64+
The ID of the emulator or device is the ID shown when running [`adb devices`](https://developer.android.com/tools/adb#devicestatus).
65+
66+
:::
67+
68+
#### Specify portal name
69+
70+
If you want to override only portals with a specific name, use the `--portal-name` flag:
71+
72+
```bash
73+
portals serve android \
74+
--application /path/to/your/android-app.apk \
75+
--dev-server http://10.0.2.2:8100 \
76+
--portal-name "profile"
77+
```
78+
### Flags:
79+
- `--device-id` **(string)** The ID of the target device.
80+
- `-h, --help` help for android
81+
82+
### Global Flags:
83+
- `--application` **(string)** Path to the native application. (required)
84+
- `--dev-server` **(string)** URL of the development server. (required)
85+
- `--capacitor-config` **(string)** Path to the capacitor configuration file.
86+
- `--portal-name` **(string)** The name of the target Portal. (default "PORTAL")
87+
- `--config` **(string)** config file (default $PWD/.portals.yaml)
88+

website/docs/cli/commands/serve-ios.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ portals serve ios [simulator | device] \
2222
--application /path/to/your/ios.app \
2323
--dev-server http://localhost:8100
2424
```
25-
This command will present an interactive list of eligible destination since no specific device details were provided. When selected, the command will launch the iOS app to the selected device and will override all portals with the content served from the development server URL by default. If a capacitor.config.{json, ts, js} file is located in the current working directory, it will use that, otherwise it will fallback to any configuration potentially shipped in the application.
25+
This command will present an interactive list of eligible destinations since no specific device details were provided. When selected, the command will launch the iOS app to the selected device and will override all portals with the content served from the development server URL by default. If a capacitor.config.{json, ts, js} file is located in the current working directory, it will use that, otherwise it will fallback to any configuration potentially shipped in the application.
2626

2727
### Examples
2828

website/docs/cli/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ curl -sL https://raw.githubusercontent.com/ionic-team/portals-cli-releases/main/
3737

3838
For Windows users, manual installation is currently required. You can download the appropriate zip file for your architecture (arm64, i386, or x86_64) from the list provided and extract it to a directory on your system's `PATH` for convenient access.
3939

40-
- [arm64](https://github.com/ionic-team/portals-cli-releases/releases/latest/downloads/portals_Windows_arm64.zip)
41-
- [i386](https://github.com/ionic-team/portals-cli-releases/releases/latest/downloads/portals_Windows_i386.zip)
42-
- [x86_64](https://github.com/ionic-team/portals-cli-releases/releases/latest/downloads/portals_Windows_x86_64.zip)
40+
- [arm64](https://github.com/ionic-team/portals-cli-releases/releases/latest/download/portals_Windows_arm64.zip)
41+
- [i386](https://github.com/ionic-team/portals-cli-releases/releases/latest/download/portals_Windows_i386.zip)
42+
- [x86_64](https://github.com/ionic-team/portals-cli-releases/releases/latest/download/portals_Windows_x86_64.zip)
4343

4444
### Linux Binaries
4545

website/sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ module.exports = {
229229
type: "category",
230230
label: "Command Reference",
231231
collapsed: true,
232-
items: ["cli/commands/poc", "cli/commands/sync", "cli/commands/serve-ios"],
232+
items: ["cli/commands/poc", "cli/commands/sync", "cli/commands/serve-ios", "cli/commands/serve-android"],
233233
},
234234
],
235235
},

0 commit comments

Comments
 (0)