You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter集成Google AdMob mediation时Unity Adapter初始化异常求助

Flutter AdMob Mediation集成Unity Ads适配器未初始化问题排查

我已完成Flutter项目中Google AdMob Mediation的基础代码实现,现在需要添加Unity Ads作为合作网络,已经将gma_mediation_unity包本地导入项目。我用以下代码验证适配器是否初始化成功:

MobileAds.instance.initialize().then((initializationStatus) {
  initializationStatus.adapterStatuses.forEach((key, value) {
    debugPrint('\n\n Mobile Adapter status for $key: ${value.description} \n\n');
  });
});

预期输出应该包含Unity适配器信息:

Mobile Adapter status for com.google.ads.mediation.unity.UnityAdapter:

但实际仅输出AdMob核心包的初始化信息:

Mobile Adapter status for com.google.android.gms.ads.MobileAds:

我已经对照gma_mediation_unity的示例项目检查过配置,确认步骤正确,但Unity Ads适配器始终未被初始化。求有AdMob Mediation集成经验的开发者帮忙排查问题。


相关配置文件

settings.gradle

pluginManagement {
def flutterSdkPath = {
    def properties = new Properties()
    file("local.properties").withInputStream { properties.load(it) }
    def flutterSdkPath = properties.getProperty("flutter.sdk")
    assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
    return flutterSdkPath
}()

repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
}


}

plugins {
  id "dev.flutter.flutter-plugin-loader" version "1.0.0"
  id "com.android.application" version "8.1.0" apply false
  id "org.jetbrains.kotlin.android" version "1.8.22" apply false
  id "com.google.gms.google-services" version "4.3.15" apply false
}

include ":app"

android/build.gradle

buildscript {
    ext.kotlin_version = '2.0.21'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}


allprojects {
    repositories {
        google()
        mavenCentral()
    }

}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

android/app/build.gradle 依赖片段

dependencies {
    implementation("com.google.android.gms:play-services-ads:23.6.0")
    implementation("com.unity3d.ads:unity-ads:4.13.1")
    implementation("com.google.ads.mediation:unity:4.13.1.0")
}

环境信息

  • Flutter版本:3.27.3
  • Gradle版本:8.5

内容的提问来源于stack exchange,提问作者Shafi Munshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 00:38:22