文档

Development

User Acquisition

Monetization

工业

Unity Ads Monetization

SDK 4.20.0

受支持
​

Android API reference

Unity Ads Monetization

SDK 4.20.0

受支持
​

此页面不支持所选语言。
Android developer guides
​
​
Android developer guide
  • Introduction to the Android SDK
  • Integration requirements
  • Install the Unity Ads SDK for Android
  • Initialize the SDK in Android
  • Implement interstitial ads in Android
  • Implement rewarded ads in Android
  • Implement banner ads in Android
Troubleshoot your integration
  • Test your Unity Ads integration
  • Unity Ads SDK troubleshooting guide
  • Introduction to Unity Ads SDK error handling
  • Troubleshoot SDK initialization errors
  • Troubleshoot SDK load errors
  • Troubleshoot SDK show errors
  • Unity Ads SDK error codes reference
Android developer APIs
  • Android SDK API reference - Kotlin and Java
  • Unity Ads SDK API deprecation policy
  • Android deprecated classes
  1. Unity Ads SDK Android developer monetization
  2. Unity Ads SDK integration guide for Android developers
  3. Unity Ads troubleshooting guide

Introduction to Unity Ads error handling

Review how and where to see Unity Ads SDK error messages to begin troubleshooting your monetization setup.
阅读时间1 分钟
最后更新于 1 个月前

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.
注意
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.

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • How to display errors

      • Use the LogLevel API

      • Set up your own logging method


报告此页面的问题
​
​