Configurare un proxy Charles per l'SDK Google Mobile Ads su Android N o versioni successive

On Android N or higher, ad calls are visible in Charles proxy only when the following steps are performed:

  1. Update the Google Play services on the mobile device.
  2. Enable Network Tracing on the mobile device.
  3. Install Charles SSL certificate on your device, and set up proxy.
  4. Enable SSL Proxy for your mobile app.

Updating the Google Play services on the mobile device

For an emulator, if you don't see the Google Play section in the side menu, you may need to update the Android Studio and download the latest system images in the Virtual Device Configuration. Make sure to use a system image with Google Play in its target.

Use the side menu to check and update Google Play services to the latest version. The minimum working version of the Google Play services is 14.5.74.

For a physical mobile device (phone or tablet), you can search for Google Play or follow this link to open Google Play directly.

Enabling Network Tracing on the mobile device

To enable network tracing, you will need to enable developer options for your device. Launch the Google Settings app and select Google > Ads > Enable debug logging for ads. A more detailed guide is available for both AdMob and Google Ad Manager publishers.

Installing Charles SSL certificate on your device, and set up proxy

To use Charles as a proxy for your mobile app, you will need to download and install Charles on a computer. Follow Charles' instructions to install an SSL certificate on the Android emulator or mobile device.

It is simpler to use the emulator with a proxy because the emulator is already connected to the same wifi network with the computer running Charles. When using the emulator with a proxy, set the proxy to localhost (http://127.0.0.1) and the port that Charles proxy is running on (found in Charles menu option Proxy > Proxy Settings).

If you're using a physical mobile device (phone or tablet), you'll need to connect the mobile device to the same wifi network with your computer running Charles using the advanced network settings. When setting up the proxy settings for your physical device, use the Charles menu option Help > Local IP address to get the IP address of your computer, to enter for the proxy address on your device (you must be on the same wifi network for this to work). Use the port that Charles proxy is running on.

Enabling SSL Proxy for your mobile app

For Charles to intercept your mobile app's SSL traffic, you will need to declare that your app can trust a user-provided SSL certificate.

First, you will need to add a new XML resource file for Network Security Configuration under the path res/xml/network_security_config.xml:

<network-security-config>
   <debug-overrides>
       <trust-anchors>
           <!-- Trust user added CAs while debuggable only -->
           <certificates src="user" />
       </trust-anchors>
   </debug-overrides>
</network-security-config>

Next, update the AndroidManifest.xml file to use the network security configuration.

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

After that, you can launch the mobile app and look for ad requests in the Charles log.

If you still have questions or need a one-on-one consultation, please reach out to your Google Technical Account Manager to sign up for office hours with our Google Ads Developer Relations team.