在 sdk gphone x86 arm 上以调试模式启动 lib/main.dart...\n运行 Gradle 任务 \'assembleDebug\'...\n\xe2\x9c\x93 构建 build/app/outputs/flutter-apk/app- debug.apk。\n正在安装 build/app/outputs/flutter-apk/app.apk...\nE/AndroidRuntime(11877): 致命异常: main\nE/AndroidRuntime(11877): 进程: com.example.truthfxac, PID: 11877\nE/AndroidRuntime(11877): java.lang.RuntimeException: 无法获取提供程序 com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:\nE/AndroidRuntime(11877):\nE/ Android运行时(11877):************************************************ *********************************\nE/AndroidRuntime(11877): * Google 移动广告 SDK 初始化不正确。AdMob 发布商 *\nE/AndroidRuntime(11877):* 应遵循此处的说明:*\nE/AndroidRuntime(11877):* https://googlemobileadssdk.page.link/admob-android-update-manifest *\nE/AndroidRuntime (11877): * 在 AndroidManifest 中添加有效的应用程序 ID。*\nE/AndroidRuntime(11877): * Google Ad Manager 广告管理系统发布商应遵循此处的说明: *\nE/AndroidRuntime(11877): * https://googlemobileadssdk.page.link/ad-manager-android-update-manifest。*\nE/AndroidRuntime(11877): ***************************************** *************************************\nE/AndroidRuntime(11877):\nE/AndroidRuntime( 11877):\nE/AndroidRuntime(11877): 在 android.app.ActivityThread.installProvider(ActivityThread.java:7244)\nE/AndroidRuntime(11877): 在 android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)\ nE/AndroidRuntime(11877):在 android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)\nE/AndroidRuntime(11877):在 android.app.ActivityThread.access$1300(ActivityThread.java:237)\nE/AndroidRuntime (11877):在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)\nE/AndroidRuntime(11877):在 android.os.Handler.dispatchMessage(Handler.java:106)\nE/AndroidRuntime(11877) ): 在 android.os.Looper.loop(Looper.java:223)\nE/AndroidRuntime(11877): 在 android.app.ActivityThread.main(ActivityThread.java:7656)\nE/AndroidRuntime(11877): 在 java .lang.reflect.Method.invoke(本机方法)\nE/AndroidRuntime(11877):位于 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)\nE/AndroidRuntime(11877):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)\nE/AndroidRuntime(11877): 原因: java.lang.IllegalStateException:\nE/AndroidRuntime(11877):\nE/AndroidRuntime(11877) :**************************************************** *****************************\nE/AndroidRuntime(11877): * Google 移动广告 …
本文适用于那些在从 firebase_admob 插件迁移到 google_mobile_ads 时遇到困难的用户。为方便起见,我将 firebase_admob 名称缩写为 FA,将 google_mobile_ads 缩写为 GMA。
据我们所知,FA 插件已停止使用并被 GMA 插件取代。FA 相对于 GMA 的优点之一是,FA 横幅将出现在整个页面上,而无需在其他页面上重写代码。但在 GMA 中,横幅仅出现在包含 GMA 代码的页面上。
与 FA 相比,GMA 有很多缺点,包括:
那么我们如何在我们的应用程序中实现 GMA 以避免出现问题呢?方式很简单,就是把一个页面变成一个tab。这只是在底部(bottomNavigation)显示横幅广告的一种方式。没有奖励或插页式广告。看看我下面的方法..
我的页面:
我将在上面的页面上显示所有横幅。
在 pubspec.yaml 上
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
google_mobile_ads: ^1.0.1
Run Code Online (Sandbox Code Playgroud)
在 android\app\build.gradle 上
...
apply plugin: 'com.google.gms.google-services'
...
android {
compileSdkVersion 32
...
...
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 32
...
multiDexEnabled true
}
... …Run Code Online (Sandbox Code Playgroud) 安装react-native-firebase_admob后,我用以下值更改了清单文件:
<application>
******
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4247389872422093~1957443376"/>
Run Code Online (Sandbox Code Playgroud)
然后我得到这个错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed :
Attribute meta-data#com.google.android.gms.ads.APPLICATION_ID@value
value=(ca-app-pub-4247389872422023~1957443376)
from AndroidManifest.xml:30:78-132
is also present at
[:@react-native-firebase_admob] AndroidManifest.xml:18:13-29
value=().
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:30:9-134
to override.
Run Code Online (Sandbox Code Playgroud) 我有一个问题,当我在 pubspec.yaml 中添加插件“ firebase_admob:^0.11.0+1”时,会出现此错误
失败:构建失败并出现异常。
- 出了什么问题:任务“:app:processDebugResources”执行失败。
执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade Android 资源链接失败 /home/mohamed/.gradle/caches/transforms-2/files-2.1/804bb16bf16b5e91bc08a39b6997ce12/play-services-ads- 时发生故障lite-19.6.0/AndroidManifest.xml:27:5-38:15: AAPT: 错误: 在 . 2
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。
在https://help.gradle.org获取更多帮助
10 秒内构建失败 构建失败可能是由于插件中的 AndroidX 不兼容。该工具即将尝试使用Jetfier来解决不兼容问题。正在构建插件 firebase_admob... 异常:由于上述问题,无法构建插件 firebase_admob。退出(sigterm)
gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
Run Code Online (Sandbox Code Playgroud)
构建.gradle:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects { …Run Code Online (Sandbox Code Playgroud) 我正在使用 react-native-firebase / admob 在 react native 中使用 Adbmod,当我尝试在第一次点击时使用插页式广告时,它会打开广告,但从那时起它返回此错误:
Error: firebase.admob () InterstitialAd.show () The requested InterstitialAd has not loaded and could not be shown.
Run Code Online (Sandbox Code Playgroud)
代码与文档相同,可在此处找到:
javascript admob react-native react-native-firebase firebase-admob
我正在尝试使用我自己的/真实的 AdUnits 而不是 TestAdUnits,但我不知道从哪里获取我的 iOS 和 Android 设备的测试设备 ID。
文档说要查看日志以找到测试 ID,但我已经检查了打印到控制台的所有内容,并且它没有打印任何设备测试 ID。
我正在 VS Code 中构建并运行我的项目
我无法在我的设备上的测试应用中显示我的广告单元。
我正在使用 firebase_admob 0.9.1+1 插件
这是我使用的代码:
import 'package:firebase_admob/firebase_admob.dart';
Future initAppAds() async {
//Récupère du coup le bon ID selon si je suis sous IOS ou Android
print(getAppId());
await FirebaseAdMob.instance.initialize(appId: 'ca-app-pub-xxxxxxxxMyAppIdxxxxxxxxxxx');
}
Future launchAds() async {
print("launchAds");
print(getInterstitialId());
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
nonPersonalizedAds: true,
);
InterstitialAd myInterstitial = InterstitialAd(
adUnitId: 'ca-app-pub-xxxxxxxxxxxxx/xxxxMyAdBloc',
targetingInfo: targetingInfo, //Info de l'utilisateur
listener: (MobileAdEvent event) {
print("InterstitialAd event is $event");
},
);
await myInterstitial.load();
await myInterstitial.show(
anchorType: AnchorType.bottom,
anchorOffset: 0.0,
horizontalCenterOffset: 0.0
);
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的日志:
2866-2866/com.fabien.movizz I/Ads: …Run Code Online (Sandbox Code Playgroud) 如何通过 Swift 包管理器将 Google admob 添加到我的 iOS 项目?我只能找到一种通过 Cocoa-pods 添加它的方法。
我将我的应用程序升级到了 Flutter 2,并使所有内容都为 null 安全。之后,我在实施 Google 移动广告 SDK 时遇到错误。
我遵循了所有文档,据此,尽管文档未更新,但我不应该收到此错误。这是我尝试实现广告的代码。
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:book_rent_app_chapter3/model/order.dart';
import 'package:book_rent_app_chapter3/provider/user.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
class OrdersScreen extends StatefulWidget {
OrdersScreen({Key? key}) : super(key: key);
@override
State<OrdersScreen> createState() => _OrdersScreenState();
}
class _OrdersScreenState extends State<OrdersScreen> {
BannerAd? _bannerAd;
@override
void initState() {
super.initState();
_bannerAd = BannerAd(
adUnitId: BannerAd.testAdUnitId,
request: AdRequest(),
size: AdSize.banner,
listener: BannerAdListener(
onAdLoaded: (Ad ad) {
print('$BannerAd loaded.');
},
onAdFailedToLoad: (Ad ad, LoadAdError error) {
print('$BannerAd failedToLoad: $error');
},
onAdOpened: (Ad ad) => …Run Code Online (Sandbox Code Playgroud) flutter google-mobile-ads firebase-admob dart-null-safety flutter2.0
admob ×6
flutter ×6
android ×4
dart ×2
firebase ×2
react-native ×2
flutter2.0 ×1
ios ×1
java ×1
javascript ×1
swift ×1