如何解决颤振包 google_mobile_ads 中的此错误

时间:2021-07-07 10:56:22

标签: android flutter googlemobileads

我正在尝试配置我的应用程序以显示测试广告,但是当我在 android 模拟器中运行该应用程序时,它崩溃并出现此错误:

 /Users/me/.pub-cache/hosted/pub.dartlang.org/google_mobile_ads-0.13.2/lib/src/ad_containers.dart:454:9: Error: A value of type 'Type' can't be assigned to a variable of type 'DiagnosticsNode'.
 - 'Type' is from 'dart:core'.
 - 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart' ('../../../flutter/packages/flutter/lib/src/foundation/diagnostics.dart').
        ErrorSummary,
        ^


FAILURE: Build failed with an exception.

* Where:
Script '/Volumes/macex/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Volumes/macex/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 56s 

我正在使用:

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.2.3 20D91 darwin-x64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.57.1)
[✓] Connected device (2 available)

• No issues found!

谢谢!

1 个答案:

答案 0 :(得分:0)

我从 https://github.com/googlecodelabs/admob-inline-ads-in-flutter 运行了示例项目 其中使用 google_mobile_ads 版本 0.13.0,而我的应用使用版本 0.13.2。

所以可能发生了某种冲突,所以我从 .pub-cache 中删除了 google_mobile_ads-0.13.* 的两个版本,然后运行 ​​flutter clean,然后重新下载软件包并更新两个应用程序以使用相同的 0.13.2 版本。

现在它似乎可以工作了。