Privacy Sandbox troubleshooting guide for Android

This document describes how to resolve common issues when setting up the Privacy Sandbox on Android. If you see an error not found in this guide, let us know.

Some errors have multiple possible reasons for being thrown. Listed below are some of the more common errors and their fixes, but it is possible to encounter the same error message for a different reason.

Before you troubleshoot

Disable device config updates

When troubleshooting any issues you're experiencing with Privacy Sandbox testing, the first step should be to disable your device config updates. This ensures that your device does not fetch updated configurations from the server and inadvertently disable Privacy Sandbox on your testing device.

Disable device config updates with this command:

adb shell device_config set_sync_disabled_for_tests persistent

If you would like to re-enable device config updates after testing, you can do so with this command:

adb shell device_config set_sync_disabled_for_tests none

Enable adservices verbose logging

Verbose logging from adservices provides more context into the errors you are seeing. To enable, use this command:

adb shell setprop log.tag.adservices VERBOSE

Make sure your device has been configured properly

If you have just disabled your device config updates, we recommend running these steps again to be sure that your device is configured properly and stays that way during the duration of your testing.

  • Enable the PPAPIs with the applicable adb commands.
  • Enroll your device, or deactivate enrollment, depending on your goals.

Check code to make sure the PPAPIs are available

You can add checks into your codebase to make sure that your device has the correct versions it needs for the Privacy Sandbox.

If you are using a Beta release via SDK extensions, check for the correct build and SDK extension version:

If you are using a Beta release via Jetpack Libraries, the initialization function returns null if the Privacy Sandbox is unavailable on your device. For example:

For any release, check for Google Play services:

Security exceptions

Security exception errors typically arise when something lacks authorization to access a Privacy Sandbox resource.

Permission was not requested

Error:

Failed to get Ad ID: java.lang.SecurityException: Caller is not authorized to call this API. Permission was not requested.

Potential Reason:

You must declare a permission to access the Ad ID.

Fix:

Declare the permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_ADSERVICES_AD_ID" />

Caller not authorized

Error:

Failed to find resolveInfo for adServices service. Intent action: android.adservices.adid.AdIdProviderService

Failed to find AdServices services

Caller not authorized

Potential Reason:

You have not enrolled your device correctly. Ensure that you have followed all enrollment instructions, including the post-enrollment steps to configure your device.

Potential Reason:

The enrollment URLs don't match.

Fix:

  1. Look at your enrollment data to see if there are discrepancies between the URL you are using in your code and the URL you registered with the Privacy Sandbox. For example, you might be using https://adtech.example.com/source but the URL registered was https://adtech.example.com/register_source
  2. Adjust your code to match the URL registered. For example, you could adjust the line in the sample app to append "/register_source" to the URL instead of "/source."

If you still see this error:

Your company may not be in the enrollment list, or the company is enrolled but not in the app's manifest allowlist. Make sure your organization is enrolled with Privacy Sandbox by contacting android-ps-support@google.com.

Caller is not allowed

Error:

Failed to get Ad ID: java.lang.SecurityException: Caller is not authorized to call this API. Caller is not allowed. Package [package name] is not allowed to call the API.

Potential Reason:

The package name is not in the allowlist.

Fix:

Allow all package names in the allowlist:

If you use adb shell directly:

The commands listed earlier work for bash and other shells, but if you start the adb shell directly and try running the commands, you are not supposed to escape the quotes. Instead, run the commands like this:

Fix:

Add your package name to the allowlist:

adb shell device_config put adservices ppapi_app_allow_list [package name]

Verify your package name is in the allowlist:

adb shell device_config get adservices ppapi_app_allow_list

If needed, you can delete the allowlist with this command:

adb shell device_config delete adservices ppapi_app_allow_list

Illegal state exceptions

Illegal state exceptions signal that a method has been invoked at an illegal or inappropriate time, where the environment or application is not in an appropriate state for the requested operation.

Illegal state exceptions: Service is not available

Error:

com.example.measurement.sampleapp E Failed binding to measurement service: java.lang.IllegalStateException: Service is not available

Potential Reason:

The kill switch must be disabled.

Fix:

You can disable the kill switch with this command:

adb shell 'device_config put adservices global_kill_switch false'

Potential Reason:

User consent has not been given.

Fix:

You can run:

adb shell am start -n com.google.android.adservices.api/com.android.adservices.ui.settings.activities.AdServicesSettingsMainActivity

After the preceding command has completed, toggle the "Enable Privacy Sandbox" preference to "On".

Errors with adb commands

Could not find job

Error:

Could not find job 14 in package com.google.android.adservices.api/ user 0

Potential Reason:

The Privacy Sandbox APIs have not been triggered.

Fix: Before running this job, call one of the Privacy Sandbox APIs, such as registerSource(), getTopics(), or selectAds(). This call is expected to fail, but is needed to activate the API. Then, re-run the jobscheduler 14 command.

Potential Reason:

Need to update Google Play Store.

Fix:

  1. Log into your device or emulator with your Google Account.
  2. Go to Google Play Store > profile icon > Settings > About. Under the Play Store version heading, tap Update Play Store.

File a ticket

If these steps don't resolve your error, file a ticket and include the following information:

  1. Which release are you using, Developer Preview or Beta? What version are you on? You can find your version code at Settings > About Phone > Build Number.
  2. If you are using a Beta release, run adb shell getprop | grep build.version.extensions and include the results in your ticket.
  3. What version of Google Play services does your device have? Run adb shell dumpsys package com.google.android.gms | grep versionName and include the results of that command in your ticket.
  4. Include a full bug report. You can get a full bug report by running adb bugreport, or by following the instructions.