Debugging Android Emulators Network Requests using Requestly

What is it?

Just like your desktop web browser has a Network Devtool panel that lets you have granular control over your Network requests. Requestly offers a similar debugging experience for Android Emulators.

The Android Emulator Network Debugger in Requestly, you can simulate different network conditions, tweak requests on the fly, and share the results easily—essentially providing a powerful extension to your development toolkit.

Why Requestly?

  • All parts of network requests can be intercepted and modified using Requestly.

  • One Click Setup

  • Save and Share Network Sessions with others

Demo

.

How to Setup?

For more manual setup guide and troubleshooting, follow the steps here

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.

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 debugging the emulator

OR

Run this command in Android Studio Terminal

adb shell settings put global http_proxy :0

What's Next?

Updated on