【发布时间】:2021-06-13 23:00:57
【问题描述】:
我的 Flutter 应用在 android 上运行良好,但是当我想使用 google admob 添加广告时,我按照此处的说明进行操作 here 但在我添加了所有要求之后,当我运行我的应用时,它给出了这个错误
Launching lib\main.dart on SM A515F in debug mode...
lib\main.dart:1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\husam\.gradle\caches\transforms-3\41205c7bc612f206229dc6e7d7c5af46\transformed\play-services-ads-lite-19.7.0\AndroidManifest.xml:27:5-43:15: AAPT: error: unexpected element <queries> found in <manifest>.
* 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 2m 44s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin firebase_admob...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.3+4\android\build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'firebase_admob'.
> Failed to apply plugin [id 'com.android.library']
> Minimum supported Gradle version is 5.1.1. Current version is 4.10.2. If using the gradle wrapper, try editing the distributionUrl in C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.3+4\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.1.1-all.zip
* 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 30s
2
Exception: The plugin firebase_admob could not be built due to the issue above.
我尝试将 gradle 版本更改为 5.1.1,但同样的错误预计将涉及其他 gradle 发行版,我也尝试运行 flutter clean 和 flutter pub cache repair
如果需要,我将分享我的代码的某些部分
此外,当我尝试添加 admob 插件和代码中所需的代码时,我遇到了这个错误
E/flutter ( 1088): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method loadBannerAd on channel plugins.flutter.io/firebase_admob)
E/flutter ( 1088): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
E/flutter ( 1088): <asynchronous suspension>
E/flutter ( 1088): #1 _invokeBooleanMethod (package:firebase_admob/firebase_admob.dart:612:23)
E/flutter ( 1088): <asynchronous suspension>
E/flutter ( 1088):
E/flutter ( 1088): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method showAd on channel plugins.flutter.io/firebase_admob)
E/flutter ( 1088): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:156
E/flutter ( 1088): <asynchronous suspension>
E/flutter ( 1088): #1 _invokeBooleanMethod (package:firebase_admob/firebase_admob.dart:612:23)
这是颤振医生命令的结果
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.2, on Microsoft Windows [Version 10.0.19042.746], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.8.3)
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Community Edition (version 2020.3)
[√] VS Code (version 1.54.3)
[√] Connected device (3 available)
! Doctor found issues in 1 category.
【问题讨论】:
-
您的应用是什么时候创建的?是新项目吗?此外,
MissingPluginException通常可以通过重建应用程序来修复。 -
我三个月前创建的新项目还有其他问题吗?
标签: android firebase flutter visual-studio-code admob