Documentation

Unity Ads Monetization


Android API reference

Unity Ads Monetization


Introduction to Unity Ads error handling

Review how and where to see Unity Ads SDK error messages to begin troubleshooting your monetization setup.
Read time 1 minuteLast updated a day ago

The Unity Ads SDK provides structured error handling to help developers identify and debug issues that occur during initialization, ad loading, or ad showing. When an operation fails, the SDK returns a
UnityAdError
object that contains both an error code and an error message describing what went wrong.
By default, these errors are returned through the SDK’s public API, but aren’t automatically printed to your development environment’s console. If you want to see them in your logs, you can either use the Unity Ads SDK APIs or set up your own logging method.
Note
In production, the recommended best practice is to route Unity Ads SDK errors through your existing logging for easier monitoring and debugging.

How to display errors

There are a couple of ways to display Unity Ads SDK error messages during development and testing. You can set SDK-generated logs or log error callbacks manually.

Use the LogLevel API

With Unity Ads SDK version 4.18.0, you can set the SDK’s internal log level to control how much information displays in the console about an error. This lets you automatically surface warnings, errors, or verbose debug output from the Unity Ads SDK without adding custom print statements. Review the LogLevel API reference and the different log verbosity levels you can set for your Kotlin and Java, Swift, or Objective-C project.

Set up your own logging method

You can also manually log SDK errors returned through callbacks using your preferred logging method by following these steps:
  1. Handle the SDK’s error callbacks.
  2. Retrieve the error code and error message from the returned object.
  3. Print or log the error using your own logging mechanism.