[英]how to properly integrate Admob in a flutter app
I've been trying to add Admob
to my flutter
application, but it keeps crashing..我一直在尝试将
Admob
添加到我的flutter
应用程序中,但它一直在崩溃。
Here is what I've tried to do:这是我尝试做的事情:
I've added This package to my pubspec.yaml
我已将此package 添加到我的
pubspec.yaml
Then I've added this meta-data
to my AndroidManifest.xml
file:然后我将此
meta-data
添加到我的AndroidManifest.xml
文件中:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-here-is-my_app_id_in_admob"/>
result结果
I get this error when I try to run the program (please note that I didn't add any ads to my .dart
files yet`当我尝试运行程序时出现此错误(请注意,我尚未在我的
.dart
文件中添加任何广告`
> File 'com.android.builder.files.ZipCentralDirectory@d8f9ce4' was deleted, but previous version not found in cache
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory@5977de6b' was deleted, but previous version not found in cache
* 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 7s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
You can run flutter clean
and it will be solved你可以运行
flutter clean
就可以解决了
From your question, it is not clear whether you use Firebase.从您的问题来看,尚不清楚您是否使用 Firebase。 You are using the "firebase_admob" package, which requires Google Service file from Firebase inside your project.
您正在使用“firebase_admob”package,这需要在您的项目中来自 Firebase 的 Google 服务文件。 If you no need a Firebase, I recommend you package admob_flutter .
如果您不需要 Firebase,我推荐您 package admob_flutter 。 This package simple and works fine in my projects (but it no support Firebase integration).
这个 package 简单并且在我的项目中工作正常(但它不支持 Firebase 集成)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.