我的XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="vertical" >
<com.google.ads.AdView android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/admob_unit_id"
ads:testDevices="@string/test_device"
ads:loadAdOnCreate="true"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
logcat 中出现错误:
11-05 09:32:30.593: I/Ads(2052): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":18,"session_id":"1804074505668833558","seq_num":"19","slotname":"a150940f47b619f","u_w":320,"msid":"com.ad.aksharamaala.hd","js":"afma-sdk-a-v6.2.1","bas_off":0,"net":"wi","app_name":"3.android.com.ad.aksharamaala.hd","hl":"en","smart_w":"full","gnt":8,"carrier":"40407","u_audio":3,"kw":[],"u_sd":1,"mv":"8015016.com.android.vending","isu":"EB83E0FCC98011A7D8B65831A838375F","cipa":0,"format":"320x50_mb","oar":0,"smart_h":"auto","ad_pos":{"height":0,"visible":1,"y":480,"x":0,"width":320},"u_h":480,"bas_on":0,"ptime":998246});</script></head><body></body></html>
11-05 09:32:30.953: W/webcore(2052): Can't get the viewWidth after the first layout
11-05 09:32:30.953: I/Ads(2052): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?preqs=18&session_id=1804074505668833558&seq_num=19&u_w=320&msid=com.ad.aksharamaala.hd&js=afma-sdk-a-v6.2.1&bas_off=0&net=wi&app_name=3.android.com.ad.aksharamaala.hd&hl=en&smart_w=full&gnt=8&carrier=40407&u_audio=3&kw&u_sd=1&mv=8015016.com.android.vending&isu=EB83E0FCC98011A7D8B65831A838375F&cipa=0&format=320x50_mb&oar=0&smart_h=auto&u_h=480&bas_on=0&ptime=998246&u_so=p&output=html®ion=mobile_app&u_tz=-330&client_sdk=1&ex=1&slotname=a150940f47b619f&kw_type=broad&askip=3&gsb=wi&caps=interactiveVideo_th_mediation_sdkAdmobApiForAds_di&jsv=40" type: "admob" afmaNotifyDt: "null" useWebViewLoadUrl: "false">
11-05 09:32:30.953: I/Ads(2052): Request scenario: Online server request.
11-05 09:32:30.973: W/Ads(2052): IOException connecting to ad url.
11-05 09:32:30.973: W/Ads(2052): java.net.ConnectException: googleads.g.doubleclick.net/127.0.0.1:80 - Connection refused
11-05 09:32:30.973: W/Ads(2052): at …Run Code Online (Sandbox Code Playgroud) 我正在尝试将代理分配给 admob 插页式广告,以便我可以处理广告事件。
GADInterstitialDelegate 实现类:
class AdDelegate: NSObject, GADInterstitialDelegate
{
//Interstitial delegate
func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
println("interstitialDidFailToReceiveAdWithError:\(error.localizedDescription)")
}
func interstitialDidReceiveAd(ad: GADInterstitial!) {
println("interstitialDidReceiveAd")
}
func interstitialWillDismissScreen(ad: GADInterstitial!) {
println("interstitialWillDismissScreen")
}
func interstitialDidDismissScreen(ad: GADInterstitial!) {
println("interstitialDidDismissScreen")
}
func interstitialWillLeaveApplication(ad: GADInterstitial!) {
println("interstitialWillLeaveApplication")
}
func interstitialWillPresentScreen(ad: GADInterstitial!) {
println("interstitialWillPresentScreen")
}
Run Code Online (Sandbox Code Playgroud)
}
委托给广告的分配:
add.delegate = AdDelegate()
Run Code Online (Sandbox Code Playgroud)
问题是广告事件没有在 AdDelegate 实现类中触发(广告正确显示)知道为什么吗?
我无法在与分配给广告对象的类相同的类中实现 GADInterstitialDelegate,因为广告对象是在类 func 中创建的,这会导致编译器错误
由于我阅读了许多Firebase AdMob相关问题及其解决方案,我对我的应用程序和CocoaPod更新做了同样的事情,但仍然面临库问题并收到以下错误:
[GADMobileAds configureWithApplicationID:@"ca-app-pub-3940256099942544~1458002511"];
Run Code Online (Sandbox Code Playgroud)
错误:所选方法 configureWithApplicationID 没有未知类
问题参考: 无法在iOS项目中更新Google AdMob
尽管如此,它仍然低于 POD 的 SDK 版本
Google-移动广告-SDK (7.8.1)
虽然我在最新版本上手动强制更新,如下所示:
pod 'Google-Mobile-Ads-SDK', '~> 7.16'
Run Code Online (Sandbox Code Playgroud)
还
pod 'Google-Mobile-Ads-SDK', '~> 7.9.1'
Run Code Online (Sandbox Code Playgroud)
参考:基于 CocoaPod 网站
target 'MyApp' do pod 'Google-Mobile-Ads-SDK', '~> 7.16' end
它会给我一个错误,例如:
Run Code Online (Sandbox Code Playgroud)[!] Unable to satisfy the following requirements: - `Google-Mobile-Ads-SDK (= 7.16)` required by `Podfile` None of your spec sources contain a spec satisfying the dependency: `Google-Mobile-Ads-SDK (= 7.16)`. You have either: * out-of-date source repos which you …
我已经关注 google admob vidoes 3 天了,但我在 logCat 中收到运行时错误:
日志猫
进程:com.exafmpflle.android.happybirthdayyyy,PID:19319 java.lang.RuntimeException:无法获取提供程序com.google.android.gms.ads.MobileAdsInitProvider:java.lang.IllegalStateException:无效的应用程序ID。请按照此处的说明进行操作:** 查找您的应用 ID。
活动主体
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:background="@drawable/january_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.exafmpflle.android.xxxxxxx.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/idbuttonfirst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/idbuttonsecond"
android:layout_marginStart="79dp"
android:background="@drawable/ic_iconaphoto"
android:src="?attr/selectableItemBackground" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-52924220005747xx/xxxxxxxx" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:layout_gravity="start"
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/navigation_menu" />
Run Code Online (Sandbox Code Playgroud)
AndroidMainfest
也在我的 Mainfest 中
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exafmpflle.android.xxxxxxx"
android:installLocation="auto">
<!-- Include required 2 permissions for Google Mobile Ads to run-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:name="android.permission.CALL_PHONE"
android:required="false" …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 AdMob 广告放入我的 ionic android 应用程序中,并测试我制作的名为 AdMobTest 的 ionic 应用程序的功能。我使用的插件是cordova-admob-pro插件。这是我的 AdMob 代码:
var admobid = {};
if (/(android)/i.test(navigator.userAgent)) { //Android
admobid = {
banner : 'ca-app-pub-2586564966169402/9782816366',
interstitial : 'ca-app-pub-2586564966169402/8345912938',
gotHereMsg1 : 'banner and interstitial have the android IDs'
};
} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { //iOS
admobid = {
banner : 'Stand in iOS banner ID',
interstitial: 'stand in iOS interstitial ID',
gotHereMsg1 : 'banner and interstitial have the iOS IDs'
};
} else { //Neither
admobid = { …Run Code Online (Sandbox Code Playgroud) 我有一个实时应用程序并在其中使用 admob 横幅。今天我收到一条警告“广告和内容重叠”
这是我放置广告横幅的 xml 代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.white.kora.Main" >
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_alignParentTop="true"
style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/progressbar_Horizontal"
android:max="100"
android:background="#228b22"
/>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|center|end"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-xxxxxxxxxxxxxxxxxxxxxx"></com.google.android.gms.ads.AdView>
Run Code Online (Sandbox Code Playgroud)
我如何正确使用带有 webview 的 admob 横幅?
最近的崩溃开始发生在各个设备制造商的每个 Android 版本中。我相信这与广告或 Google 的组件之一有关。
我在这里自己打开了一个问题:https : //issuetracker.google.com/issues/149665852
设备相关信息(从2k用户到43个用户有48个异常,发生在3天内)
堆栈跟踪(包名因保密而隐藏):
Caused by java.util.ConcurrentModificationException
at androidx.collection.SimpleArrayMap.put + 461(SimpleArrayMap.java:461)
at com.google.android.gms.measurement.internal.zzin.zza + 108(zzin.java:108)
at com.google.android.gms.measurement.internal.zzid.onActivityCreated + 11(zzid.java:11)
at android.app.Application.dispatchActivityCreated + 189(Application.java:189)
at android.app.Activity.onCreate + 962(Activity.java:962)
at androidx.core.app.ComponentActivity.onCreate + 81(ComponentActivity.java:81)
at androidx.activity.ComponentActivity.onCreate + 149(ComponentActivity.java:149)
at androidx.fragment.app.FragmentActivity.onCreate + 313(FragmentActivity.java:313)
at androidx.appcompat.app.AppCompatActivity.onCreate + 106(AppCompatActivity.java:106)
at com.example.myapp.MainActivity.onCreate + 35(MainActivity.java:35)
at android.app.Activity.performCreate + 6147(Activity.java:6147)
at android.app.Instrumentation.callActivityOnCreate + 1112(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity + 2498(ActivityThread.java:2498)
at android.app.ActivityThread.handleLaunchActivity + 2625(ActivityThread.java:2625)
at android.app.ActivityThread.access$700 + 183(ActivityThread.java:183)
at android.app.ActivityThread$H.handleMessage + 1484(ActivityThread.java:1484)
at android.os.Handler.dispatchMessage …Run Code Online (Sandbox Code Playgroud) 这不是这篇文章的重复(他们更新了错误的文件)。
\n收到错误
\njava.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: \njava.lang.IllegalStateException:\n\n******************************************************************************\n* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers *\n* should follow the instructions here: *\n* https://googlemobileadssdk.page.link/admob-android-update-manifest *\n* to add a valid App ID inside the AndroidManifest. *\n* Google Ad Manager publishers should follow instructions here: *\n* https://googlemobileadssdk.page.link/ad-manager-android-update-manifest. *\n******************************************************************************\nRun Code Online (Sandbox Code Playgroud)\n即使我更新 ..\\app\\src\\main\\AndroidManifest.xml
\n<meta-data \n android:name="com.google.android.gms.ads.APPLICATION_ID" \n android:value="ca-app-pub-1234567890123456~1234567890"/>\nRun Code Online (Sandbox Code Playgroud)\n我遵循了几个教程和帖子,但总是得到相同的结果。
\n我在 main.dart 中初始化为
\nFirebaseAdMob.instance.initialize(appId: "ca-app-pub-1234567890123456~1234567890");\nRun Code Online (Sandbox Code Playgroud)\n这是我的完整错误报告:
\nLaunching lib\\main.dart on Android SDK built …Run Code Online (Sandbox Code Playgroud) 我正在使用 Google AdMob v8 在同一视图控制器中实现插页式广告和奖励广告。
我需要能够确定哪个广告被忽略,以便我可以正确加载另一个广告。
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd)
loadRewarded()
loadInterstitial()
}
Run Code Online (Sandbox Code Playgroud)
我上面的进度是加载奖励广告和插页式广告,无论哪个广告被驳回。
如何确定哪个广告(插页式广告或奖励广告)被驳回?
我收到一条消息:
添加或更新 app-ads.txt
您的 app-ads.txt 文件丢失或无效。为防止广告收入出现重大损失,请添加或更新您的 app-ads.txt。
将 app-ads.txt 发布到开发者网站的根目录(例如,sampledomain.com/app-ads.txt)。确保输入的域名与 Google Play 或 App Store 中列出的完全一致。
我没有开发者网站。
我的要求:如何免费设置这个app-ads.txt文件?(我没有域名或网站)
admob ×10
android ×6
ios ×2
swift ×2
ads ×1
cordova ×1
dart ×1
firebase ×1
flutter ×1
interstitial ×1
java ×1
javascript ×1
objective-c ×1
subdomain ×1
web-hosting ×1