Proxyman iOS
Sample Android Project

1. What's it?

Intercepting HTTPS traffic on Android Devices and Android Emulators is more complicated than on iOS.
If you've struggled to config XML settings, let's check out this sample project that we've already configured for you:
Check out the Sample Config section to understand how the config is set up.
Android OKHTTP + Proxyman

2. Prepare

  • Android Studio
  • Pixel 5 Emulator with API 31+ (We suggest that we should create a brand-new Emulator device rather than using the current one. Visit Android Virtual Devices windows in Android Studio)
  • Clone or download the project at https://github.com/ProxymanApp/OKHTTP-Android-Sample

3. Configuration

You might either follow steps 3.1 or 3.2:

3.1 Android Emulator with the Automatic Script

If you run this project on Android Emulator (Google APIs version), you can check out the Automatic Script and Proxyman provides to:
  1. 1.
  2. 2.
    Make sure you can run the project in Android Studio with Android Emulator (API 31)
  3. 3.
    Open Proxyman -> Certificate Menu -> Install Certificate for Android -> Emulator
  4. 4.
    Click on the "Override Emulator" button to automatically set the HTTP Proxy & Install & Trust the certificate.
  5. 5.
    You don't need to config the file res/xml/network_security_config.xml and AndroidManifest.xml since the project is already configured.
  6. 6.
    Back to the Emulator -> Click on Say Hello -> Observe the HTTPS log on Proxyman
  7. 7.
    Done

3.2 Physical Android Devices

For Physical Devices or Emulator (without using the automatic script), it's more complicated and error-prone. Please carefully follow each following steps:

3.2.1 Set HTTP Proxy to Proxyman

  1. 1.
    Open your Android Device -> Setting app -> Wifi: Make sure your Wifi connection is good. Sometimes, it's "Limited Connection" that you could not set the Wifi Proxy. If it happens, please remove the emulator and create a new one again.
  2. 2.
    Click on the Wifi then clicking on Edit Button.
  3. 3.
    Start set HTTP Proxy that the same IP and Port value from Android Guideline (Proxyman app -> Certificate -> Install Certificate on Android Devices)
Make sure the Proxy Hostname and Port match with the values in (Proxyman app -> Certificate -> Install Certificate on Android Devices)

2.3 Download and Install Proxyman Certificate

  1. 1.
    Open Google Chrome on your Android devices
  2. 3.
    Download the Certificate and select VPN and App Category
On Android 12+, If you encounter this warning "Can't install the Certificate: This file can't be used as a VPN & app user certificate", please try to select "CA Certificate" instead.
4. On Android 11 and Android 12. Let's verify by opening Trusted Credentials -> User Tab.
Make sure you can see Proxyman CA Certificate like the below screenshot.

5. You don't need to config the file res/xml/network_security_config.xml and AndroidManifest.xml since the project is already configured.
6. Back to the Emulator -> Click on Say Hello -> Observe the HTTPS log on Proxyman
7. Done

4. Sample Config

  • AndroidManifest.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
package="io.approov.shapes">
4
5
<uses-permission android:name="android.permission.INTERNET" />
6
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7
8
<application
9
android:allowBackup="true"
10
android:icon="@mipmap/ic_launcher"
11
android:label="@string/app_name"
12
android:roundIcon="@mipmap/ic_launcher"
13
android:supportsRtl="true"
14
android:theme="@style/AppTheme"
15
android:name="io.approov.shapes.ShapesApp"
16
android:networkSecurityConfig="@xml/network_security_config"
17
>
18
<activity android:name=".MainActivity" android:exported="true">
19
<intent-filter>
20
<action android:name="android.intent.action.MAIN" />
21
<category android:name="android.intent.category.LAUNCHER" />
22
</intent-filter>
23
</activity>
24
</application>
25
26
</manifest>
Copied!
  • res/xml/network_security_config.xml
1
<network-security-config>
2
<debug-overrides>
3
<trust-anchors>
4
<!-- Trust user added CAs while debuggable only -->
5
<certificates src="user" />
6
<certificates src="system" />
7
</trust-anchors>
8
</debug-overrides>
9
10
<base-config cleartextTrafficPermitted="true">
11
<trust-anchors>
12
<certificates src="system" />
13
</trust-anchors>
14
</base-config>
15
16
<domain-config>
17
<!-- Make sure your URL Server here -->
18
<domain includeSubdomains="true">shapes.approov.io</domain>
19
<domain includeSubdomains="true">httpbin.org</domain>
20
<trust-anchors>
21
<certificates src="user"/>
22
<certificates src="system"/>
23
</trust-anchors>
24
</domain-config>
25
</network-security-config>
Copied!

4. Troubleshooting

Depend on Android Emulator and APIs version, you might encounter some errors.
1.After setting the Wifi Proxy in Android Studio, I could not visit http://proxy.man/ssl
=> Please try to restart the Emulator and make sure the Wifi Status in Emulator is "Connected"
=> Delete your Android Emulator and create a new one
2. I get SSL Errors when intercepting HTTPS traffics
=> Sometimes, your Android Emulator doesn't load Proxyman Certificates => Please stop the project and start again.
=> Make sure your domains are listed in res/xml/network_security_config.xml
3. Android Device connection is often dropped and hardly connect
=> Try to add 8.8.8.8 as a DNS on your current Mac Wifi.