Android Emulators

How to Debug Android Emulators using Requestly

.

Setup

0. Prerequisites

  1. Download the Requestly Desktop app, if you haven’t already.
  1. Start your Android App on the emulator.

1. Setup Proxy & Certificates

Works only with Requestly Desktop App >v1.7.0

  1. Click Connect Apps
  1. Go to Mobile Apps & Browsers tab.
  1. Click on Connect button of emulator you want to connect to.

Not seeing your emulator? Follow these steps.

2. [if-required] SSL Pinning

Only required on Android API level >= 23 (Android 7+).

Make sure to remove these in production builds

Add these configs to your app codebase for it to work

  1. Add res/xml/network_security_config.xml
<network-security-config>
  <debug-overrides>
    <trust-anchors>
      <certificates src="user" />
      <certificates src="system" />
    </trust-anchors>
  </debug-overrides>

  <base-config cleartextTrafficPermitted="true">
    <trust-anchors>
      <certificates src="system" />
      <certificates src="user" />
    </trust-anchors>
  </base-config>
</network-security-config>
  1. Add to AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config" ... >
    ...
    </application>
</manifest>

3. Deactivate Proxy (After done debugging)

Please make sure to revert the proxy after you are done testing using Requestly

 adb shell settings put global http_proxy :0

Troubleshooting

Emulator not detected?

  • Check if your emulator is running?

  • Check if adb is installed. If not, install it from here

  • Try Restarting your emulator.

How does it work?

Here's the code that makes this happen in a single click

https://github.com/requestly/requestly-desktop-app/blob/fb1f321a3d2431cfcd9d95d1396bcd39820a4ec9/src/renderer/actions/apps/mobile/android.js#L63-L74

  1. Searches for online ADB devices

  2. On Connect

    1. Root the device (To install Requestly CA)

    2. Inject Requestly CA (if not already)

    3. Setup Proxy on Emulator

    4. Restart the Emulator (Only first time)

  3. On Disconnect - Removes the Proxy

Updated on