如何解决颤振包 google_mobile_ads 中的此错误
Posted
技术标签:
【中文标题】如何解决颤振包 google_mobile_ads 中的此错误【英文标题】:How can I resolve this error in the flutter package google_mobile_ads 【发布时间】:2021-09-17 22:07:50 【问题描述】:我正在尝试将我的应用配置为显示测试广告,但是当我在 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!
谢谢!
【问题讨论】:
从错误日志中我的理解是,>A value of type 'Type' can't be assigned to a variable of type > 'DiagnosticsNode'
在代码的某处出现了类型转换问题。它期望DiagnosticsNode
类型的值,但提供Type
类型。
【参考方案1】:
我已经从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版本。
现在它似乎工作了。
【讨论】:
以上是关于如何解决颤振包 google_mobile_ads 中的此错误的主要内容,如果未能解决你的问题,请参考以下文章
使用颤振如何将音频文件与任何视频(如相机动作)的同步合并,颤振中有任何特定的包可用