Skip to content
subcloakdocs

Devices and runtimes

Android

Capture an Android emulator or USB device with one click through adb, install the Cloak Proxy certificate, and let your app trust user certificates.

Cloak Proxy can set up an Android emulator or a USB-connected Android device for you through adb, the Android Debug Bridge. It forwards the device’s proxy port to your Mac, sets the device’s proxy, and copies the certificate to it. Because Android apps ignore user-installed certificates by default, your app also needs a small network security config in its debug build.

The Android page when adb is installed.

  1. Forwards the port and sets the device's proxy
  2. Removes the proxy and the port forward
  3. Copies the certificate to the device's Downloads folder
  4. Lists the devices adb can see
The Android page of Device & Runtime Setup with Connect Proxy, Disconnect Proxy, Push Certificate and Show Connected Devices buttons, and the Let your debug build trust Cloak Proxy section with a network security config

The one-click buttons need adb. Cloak Proxy looks for it in these places, in order:

Location Installed by
/opt/homebrew/bin/adb Homebrew on Apple silicon
/usr/local/bin/adb Homebrew on Intel, or a manual install
/usr/bin/adb A manual install
~/Library/Android/sdk/platform-tools/adb Android Studio’s SDK Manager

If it finds none, the Android page shows adb wasn’t found. Install Android platform tools (brew install android-platform-tools) for one-click setup. in place of the buttons.

Terminal
brew install android-platform-tools

After installing, switch to another tab and back, or reopen the window, so Cloak Proxy finds adb.

The Emulator or USB-connected device (adb) section uses adb reverse, so the device reaches Cloak Proxy over USB or the emulator bridge. You don’t need to change Wi-Fi settings on the device or let other devices connect to the Mac.

  1. Start the emulator, or connect the device with a USB cable and turn on USB debugging in its Developer options. Accept the prompt on the device to allow your Mac.

  2. Open Device & Runtime Setup (click Devices in the toolbar) and choose Android in its sidebar.

  3. Click Show Connected Devices to confirm adb sees exactly one device.

  4. Click Connect Proxy.

    The output area shows Proxy set to 127.0.0.1:9090 on the device. If either command fails, it shows adb’s error instead.

  5. Click Push Certificate, then install it on the device. See Install the certificate.

The buttons use the port Cloak Proxy is listening on (9090 by default).

Button Commands it runs Result message
Connect Proxy adb reverse tcp:9090 tcp:9090, then adb shell settings put global http_proxy 127.0.0.1:9090 Proxy set to 127.0.0.1:9090 on the device.
Disconnect Proxy adb shell settings put global http_proxy :0, then adb reverse --remove tcp:9090 Proxy removed from the device.
Push Certificate adb push <certificate> /sdcard/Download/cloak-proxy-ca.crt Copied to Downloads. On the device: Settings → Security → Encryption & credentials → Install a certificate → CA certificate.
Show Connected Devices adb devices -l The list of devices, with their model names.

adb reverse makes port 9090 on the device lead to port 9090 on your Mac, so the device’s proxy can be 127.0.0.1:9090. The global http_proxy setting is Android’s device-wide proxy, which apps that use the system proxy follow for both HTTP and HTTPS.

Since 0.5.1

The device’s proxy, 127.0.0.1:9090, only reaches your Mac through the adb reverse forward. Unplugging the cable, restarting the emulator or restarting the adb server ends the forward, but the proxy setting stays, so the device has no internet at all.

While adb is running, the Doctor checks each device whose proxy is on its own loopback with adb reverse --list. When the forward for the proxy’s port is gone, it reports a problem, adb reverse is gone: the device has no internet, on the Doctor and at the top of the Android page, with Re-run adb reverse. That runs adb -s <device> reverse tcp:9090 tcp:9090 and leaves the device’s proxy setting alone.

An emulator still pointed at 127.0.0.1:9090 after adb lost its forward.

The Android page of Device & Runtime Setup with a red problem: adb reverse is gone, the device has no internet, with the evidence http_proxy is 127.0.0.1:9090 and adb reverse --list: no forwards, and a Re-run adb reverse button

The Doctor never starts adb: it only checks while the adb server is already running, so a device that was unplugged with adb stopped shows up once you start adb again (for example by plugging it back in and clicking Show Connected Devices). If you’re done capturing, click Disconnect Proxy instead to clear the device’s proxy.

With an assistant, capture_setup with target android lists the same step (android-reverse), and applying it re-runs adb reverse.

Push Certificate copies the Cloak Proxy root certificate to the device’s Download folder as cloak-proxy-ca.crt. Android then needs you to install it.

  1. On the device, open Settings › Security › Encryption & credentials. On some devices it’s under Settings › Security & privacy › More security settings or a similar path; search Settings for “certificate” if you can’t find it.

  2. Tap Install a certificate, then CA certificate.

  3. Android warns that a CA lets others see your data. Tap Install anyway.

  4. Choose cloak-proxy-ca.crt from the Download folder and confirm with the screen lock if asked.

The certificate is now a user certificate. Android’s browser and apps that opt in trust it. Most apps don’t trust it yet: see the next section.

You can also get the certificate without adb: once the device’s proxy points at Cloak Proxy, open http://cloak.proxy in the device’s browser and tap Download certificate (DER, Android / Windows). See Other devices and access control.

Since 0.4.0

Apps targeting Android 7 (API level 24) or later ignore user-installed certificates unless their network security config allows it. Cloak Proxy writes that config into your app’s src/debug source set, so release builds don’t change.

The files Cloak Proxy wrote into a project's src/debug.

The Android page's Let your debug build trust Cloak Proxy section: Bundle the Cloak Proxy certificate chosen, an empty domains field, the project folder, three files created in src/debug and the generated network_security_config.xml
  1. On the Android page of Device & Runtime Setup, choose how the app trusts Cloak Proxy:

    Choice What it writes On the device
    Bundle the Cloak Proxy certificate (default) The config with <certificates src="@raw/cloak_proxy_ca" /> and the certificate as res/raw/cloak_proxy_ca.pem Nothing to install
    Trust user-installed certificates The config with <certificates src="user" /> Install the certificate (Push Certificate, above)
  2. Optionally type domains in Only for domains (api.example.com, example.org) to trust Cloak Proxy for those domains and their subdomains only. Empty means every domain.

  3. Click Add to Project… and pick your Android project, its app module, or a Flutter project (Cloak Proxy finds app/ or android/app/). The section lists each file it will create or update.

  4. Click Write N Files, then build and install a debug build.

File When
src/debug/res/xml/network_security_config.xml Always. If src/main already has a config (the manifest’s android:networkSecurityConfig), Cloak Proxy copies it into src/debug under the same name and adds its trust to it, so your other settings stay.
src/debug/res/raw/cloak_proxy_ca.pem With Bundle the Cloak Proxy certificate
src/debug/AndroidManifest.xml When no manifest names a config yet. Gradle merges it into debug builds only. An existing debug manifest gets the attribute added.

Writing again changes nothing once the files are in place. To undo, delete the files Cloak Proxy created in src/debug.

You can’t add this to apps you don’t build, so most third-party apps on Android 7 and later can’t be decrypted.

AI assistants use capture_config with kind: "android_network_config" (or capture_setup with apply: "network-security-config"); in Terminal, cloakctl capture-config android --project . --write.

Then add your API’s host to SSL Proxying so Cloak Proxy decrypts it.

For a device you can’t connect over USB, use the Wi-Fi proxy, the same way as an iPhone.

  1. In Cloak Proxy, turn on Allow other devices to connect (phones, other computers) in Settings › General and click Apply & Restart Proxy. The setting shows This Mac’s address, for example 192.168.1.20:9090.

  2. On the device, open the Wi-Fi network’s settings, find Proxy (often under Advanced options), and choose Manual.

  3. Enter your Mac’s address as the proxy hostname and 9090 as the port, then save.

  4. Open http://cloak.proxy in the device’s browser, tap Download certificate (DER, Android / Windows), and install it as a CA certificate.

The exact Wi-Fi settings path differs between Android versions and manufacturers. Traffic from a Wi-Fi device appears in the sidebar under its IP address.

  1. Click Disconnect Proxy. It clears the device’s proxy and removes the port forward. Do this before you unplug the device or quit Cloak Proxy: a device whose proxy is 127.0.0.1:9090 without the forward can’t reach the internet.

    Without Cloak Proxy, run the same commands yourself:

    Terminal
    adb shell settings put global http_proxy :0
    adb reverse --remove tcp:9090

    If the device has no internet after you unplug it, its proxy is still set: plug it back in and click Disconnect Proxy, or on the device clear Settings › Network › Proxy.

  2. Remove the certificate on the device: open Settings › Security › Encryption & credentials › User credentials (or Trusted credentials › User), select the Cloak Proxy CA, and remove it. Delete cloak-proxy-ca.crt from Download too.

  3. If you used Wi-Fi, set the network’s proxy back to None, and turn off Allow other devices to connect on the Mac.

If you regenerate the root certificate in Settings › Certificate, push and install the new one.