无法使用颤振项目的测试设备(模拟器)加载测试广告



我是 Flutter 应用程序项目的新手。我根据 https://firebase.google.com/docs/android/setup 配置了我的应用程序

输出控制台

在调试模式下为 x86 构建的 Android SDK 上启动 lib\main.dart... 正在初始化分级... 正在解析依赖项... 运行 Gradle 任务 'assembleDebug'... registerResGeneratingTask 已弃用,使用 registerGenerated ResFolder(FileCollection) registerResGeneratingTask 已弃用,使用 registerGenerated ResFolder(FileCollection) registerResGeneratingTask 已弃用,使用 registerGenerated ResFolder(FileCollection) registerResGeneratingTask 已弃用,使用 registerGenerated ResFolder(FileCollection) registerResGeneratingTask 已弃用,使用 registerGenerated ResFolder(FileCollection) 构建构建\应用程序\输出\apk\调试\应用程序调试.apk. D/网络安全配置(17748):未指定网络安全配置,使用平台默认值 I/WebViewFactory(17748):正在加载 com.android.chrome 版本 69.0.3497.100(代码 349710017) I/jokes.jokespun(17748):ClassLoaderContext 是一个特殊的共享库。 I/jokes.jokespun(17748):ClassLoaderContext 是一个特殊的共享库。 将文件同步到为 x86 构建的设备 Android SDK... I/jokes.jokespun(17748): 后台并发复制 GC 释放 14545(2MB) 分配空间对象, 9(176KB) LOS 对象, 50% 可用, 1808KB/3MB, 暂停 5.468ms 总计 87.502ms I/cr_LibraryLoader(17748):加载本机库的时间:19 毫秒(时间戳 870-889) I/chromium(17748): [INFO:library_loader_hooks.cc(36)] 已启用铬日志记录:级别 = 0,默认详细程度 = 0 I/cr_LibraryLoader(17748):预期的本机库版本号"69.0.3497.100",实际本机库版本号"69.0.3497.100" W/cr_ChildProcLH(17748): 创建一个新的 ChildConnection分配器,包名称 = com.android.chrome,沙盒 = true I/cr_BrowserStartup(17748): 初始化铬进程,单进程=假 I/chromium(17748): [INFO:aw_field_trial_creator.cc(54)] 未找到第一个网络视图实验 I/FA (17748):找不到跟踪代码管理器,因此不会使用 I/OpenGLRenderer(17748):初始化的 EGL,版本 1.4 D/OpenGLRenderer(17748):交换行为 1 D/(17748): 主机连接::get() 新主机连接建立0xc27781c0, tid 17839 W/OpenGLRenderer(17748): 无法选择带有 EGL_SWAP_BEHAVIOR_PRESERVED 的配置,在没有... D/OpenGLRenderer(17748): 交换行为 0 D/EGL_emulation(17748): eglCreateContext: 0xe06ee060: maj 3 min 0 rcv 3 W/jokes.jokespun(17748): 访问隐藏字段 Ljava/nio/Buffer;->地址:J (浅灰名单,反射) D/EGL_emulation(17748): eglMakeCurrent: 0xe06ee060: ver 3 0 (tinfo 0xc2737970) D/EGL_emulation(17748): eglCreateContext: 0xe06eed20: maj 3 min 0 rcv 3 D/EGL_emulation(17748): eglMakeCurrent: 0xe06eed20: ver 3 0 (tinfo 0xe076e4e0) V/FA (17748):推迟到 Google Analytics for Firebase 进行事件数据收集。 D/DynamitePackage(17748): Instanceiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl I/DynamiteModule(17748):考虑本地模块com.google.android.gms.ads.dynamite:0和远程模块com.google.android.gms.ads.dynamite:11140 I/DynamiteModule(17748):选定的远程版本的com.google.android.gms.ads.dynamite,版本>= 11140 V/DynamiteModule(17748):炸药装载机版本>= 2,使用loadModule2NoCrashUtils D/DynamitePackage(17748): Instanceiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl I/Ads (17748):正在发起广告请求。 I/Ads (17748): SDK 版本: afma-sdk-a-v15090040.14300000.1 I/Ads (17748):此请求从测试设备发送。 W/Ads (17748):找不到com.google.android.gms.ads.AdActivity,请确保它在AndroidManifest.xml中声明。 I/编舞(17748):跳过了39帧! 应用程序可能在其主线程上做了太多工作。 D/EGL_emulation(17748): eglMakeCurrent: 0xe06ee060: ver 3 0 (tinfo 0xc2737970) I/OpenGLRenderer(17748):Davey!持续时间=826毫秒;标志=1, 预期Vsync=15091144858940, Vsync=15091794858914, 最旧的输入事件=9223372036854775807, 最新输入事件=0, 句柄输入开始=15091808987960, 动画开始=15091809076260, 执行遍历开始=15091809263460, 绘制开始=15091820381260, 同步队列=15091822369660, 同步启动=15091827238560, 问题绘制命令开始=15091833671660, 交换缓冲区=15091871677860, 帧完成=15091976321160, 取消队列缓冲区持续时间=59743000, 队列缓冲区持续时间=370000, W/cr_CrashFileManager(17748):/data/user/0/puns.jokes.jokespuns/cache/WebView/Crash Reports 不存在或不是目录 D/(17748): 主机连接::get() 新主机连接建立0xdf4d9a00, TID 17773 D/EGL_emulation(17748): eglMakeCurrent: 0xe06eed20: ver 3 0 (tinfo 0xe076e710) D/skia (17748): 程序链接失败。I/chatty (17748): uid=10086(双关语.jokes.jokespuns) 1.gpu 相同的 7 行 D/skia (17748): 程序链接失败。 D/skia (17748): 程序链接失败。

我正在尝试将AdMob包含在我的Android颤振项目中。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="puns.jokes.package.unique">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Jokes and Puns"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-<appid>"/>
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

Build.gradle

buildscript {
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
}allprojects {
repositories {
google()
jcenter()
}
}rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}subprojects {
project.evaluationDependsOn(':app')
}task clean(type: Delete) {
delete rootProject.buildDir}

App/Build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '2.0.0'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '2.0.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "puns.jokes.jokespuns"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-ads:17.1.3'
implementation 'com.google.android.gms:play-services-ads:17.1.3'
//    testImplementation 'junit:junit:4.12'
//    androidTestImplementation 'com.android.support.test:runner:1.0.2'
//    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

main_screen.飞镖

@override
void initState() {
super.initState();
FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
}
@override
Widget build(BuildContext context) {
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords: <String>['flutterio', 'beautiful apps'],
testDevices: <String>[], // Android emulators are considered test devices
);
myInterstitial = InterstitialAd(
// Replace the testAdUnitId with an ad unit id from the AdMob dash.
// https://developers.google.com/admob/android/test-ads
// https://developers.google.com/admob/ios/test-ads
adUnitId: InterstitialAd.testAdUnitId,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("InterstitialAd event is $event");
},
);
myInterstitial..load()..show();
}
.....
.....
.....
.....
.....
@override
void dispose() {
myInterstitial.dispose();
super.dispose();
}

没有任何错误或警告的广告。

将此部分移到活动之外

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-<appid>"/>

最新更新