Skip to content
TestsigmaDOCS

Help

How to Capture Network Logs in an Android Application?

Step 1: Create a network security configuration XML file

Section titled “Step 1: Create a network security configuration XML file”
  1. Create the res/xml directory in your project if it does not exist.

  2. Create a new XML file named network_security_config.xml.

  3. Add the following content:

    <network-security-config>
    <base-config>
    <trust-anchors>
    <!-- Trust preinstalled CAs -->
    <certificates src="system" />
    <!-- Trust user-added CAs (needed for proxies) -->
    <certificates src="user" />
    </trust-anchors>
    </base-config>
    </network-security-config>

This configuration allows your app to trust user-installed certificates, enabling proxy tools to capture network logs.

Step 2: Update the Application Manifest File

Section titled “Step 2: Update the Application Manifest File”
  1. Open AndroidManifest.xml.

  2. Locate the tag.

  3. Add the android:networkSecurityConfig attribute:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config">
    ...
    </application>
    </manifest>

Now, your app will use the specified network security configuration and allow network logs to be captured.