Tối ưu hoá hoạt động khởi chạy và tải quảng cáo
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Chọn nền tảng:
Android
Unity
Kể từ SDK Quảng cáo trên thiết bị di động của Google (GMA) phiên bản 21.0.0, bạn có thể bật tính năng khởi chạy SDK và tải quảng cáo được tối ưu hoá để cải thiện khả năng phản hồi tổng thể của quảng cáo và giúp ngăn chặn lỗi "Ứng dụng không phản hồi" (ANR) trên ứng dụng của bạn. Hướng dẫn này trình bày những thay đổi mà bạn cần thực hiện để bật các hoạt động tối ưu hoá này.
Yêu cầu
- Trình bổ trợ Unity quảng cáo trên thiết bị di động của Google phiên bản 7.2.0 trở lên.
Cập nhật chế độ cài đặt Quảng cáo trên thiết bị di động của Google
SDK quảng cáo trên thiết bị di động của Google
cho phép tối ưu hoá theo mặc định và hướng dẫn SDK thực hiện các tác vụ xử lý hoạt động khởi chạy và tải quảng cáo trên các luồng nền.
Các cờ sau đây có sẵn cho đối tượng có thể viết kịch bản chế độ cài đặt SDK quảng cáo trên thiết bị di động của Google:
- Tắt tính năng tối ưu hoá quá trình khởi chạy
- Tắt tính năng tối ưu hoá hoạt động tải quảng cáo
Kiểm tra các chế độ cài đặt này để hướng dẫn SDK khởi chạy và tải quảng cáo trên luồng chính:
Cài đặt | Hành vi |
Tắt tính năng Tối ưu hoá hoạt động khởi chạy |
Tắt tính năng tối ưu hoá lệnh gọi khởi chạy MobileAds.initialize() . |
Tắt tính năng tối ưu hoá hoạt động tải quảng cáo
|
Tối ưu hoá lệnh gọi tải quảng cáo cho tất cả định dạng quảng cáo. |
Tắt tính năng tối ưu hoá lệnh gọi tải quảng cáo. |
Bạn có thể truy cập vào phần cài đặt Quảng cáo trên thiết bị di động của Google thông qua trình đơn thành phần của Unity:
Assets > Google Mobile Ads > Settings
Sau khi được chọn, giao diện người dùng của phần cài đặt sẽ xuất hiện trong cửa sổ trình kiểm tra Unity Editor.

Xin lưu ý rằng bạn có thể bật một hoặc cả hai loại cờ trong cùng một ứng dụng.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-27 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-27 UTC."],[[["\u003cp\u003eStarting with Google Mobile Ads SDK version 21.0.0, you can optimize SDK initialization and ad loading to enhance ad responsiveness and mitigate ANR errors.\u003c/p\u003e\n"],["\u003cp\u003eThese optimizations are enabled through two flags within the Google Mobile Ads settings: \u003cstrong\u003eOptimize Initialization\u003c/strong\u003e and \u003cstrong\u003eOptimize AdLoading\u003c/strong\u003e, which offload time-consuming tasks to background threads.\u003c/p\u003e\n"],["\u003cp\u003eYou can access and modify these settings via the Unity asset menu: \u003cstrong\u003eAssets > Google Mobile Ads > Settings\u003c/strong\u003e, enabling either or both options based on your needs.\u003c/p\u003e\n"],["\u003cp\u003eBy default, both optimization flags are set to \u003ccode\u003efalse\u003c/code\u003e, requiring you to manually enable them to leverage these improvements.\u003c/p\u003e\n"]]],["Optimized SDK initialization and ad loading can be enabled in Google Mobile Ads (GMA) SDK version 21.0.0 and higher, preventing \"Application Not Responding\" (ANR) errors. To activate, update to Google Mobile Ads Unity plugin version 7.2.0 or higher. In Unity's **Assets \u003e Google Mobile Ads \u003e Settings**, enable **Optimize Initialization** and/or **Optimize AdLoading**. These settings offload initialization and ad loading to background threads. Both flags are `false` by default.\n"],null,["# Optimize initialization and ad loading\n\nSelect platform: [Android](/admob/android/optimize-initialization \"View this page for the Android platform docs.\") [Unity](/admob/unity/optimize-initialization \"View this page for the Unity platform docs.\")\n\n\u003cbr /\u003e\n\nStarting from Google Mobile Ads (GMA) SDK version 21.0.0, you can enable\noptimized SDK initialization and ad loading to improve the overall\nresponsiveness of ads and help prevent [\"Application Not Responding\"\n(ANR)](//developer.android.com/topic/performance/vitals/anr) errors on your app.\nThis guide outlines the changes you need to make to enable these optimizations.\n\nRequirements\n------------\n\n- Complete the [Get Started guide](/admob/unity/quick-start).\n\n\u003c!-- --\u003e\n\n- Google Mobile Ads Unity plugin version 7.2.0 or higher.\n\nUpdate your Google Mobile Ads settings\n--------------------------------------\n\nThe\n\nGoogle Mobile Ads SDK\n\nenables optimization by default, and instructs the SDK to\nperform initialization and ad loading tasks processing on background threads.\n\nThe following flags are available for the\n\nGoogle Mobile Ads SDK\n\nsettings scriptable\nobject:\n\n- Disable initialization optimization\n- Disable ad loading optimization\n\nCheck these settings to instruct the SDK to initialize and load ads on the main\nthread:\n\n| Setting | Behavior |\n|---------------------------------|-----------------------------------------------------------------------|------------------------------------------|\n| Disable Optimize Initialization | Disables optimizing the `MobileAds.initialize()` initialization call. |\n| Disable ad loading optimization | Optimizes ad load calls for all ad formats. | Disables optimizing the ad loading call. |\n\nYou can access the Google Mobile Ads settings through the Unity asset menu:\n\n**Assets \\\u003e Google Mobile Ads \\\u003e Settings**\n\nOnce selected, the settings UI appears in your Unity Editor inspector window.\n\nNote that you can turn on one or both options in the same app."]]