gpt4 book ai didi

android - MoPub 原生广告和 Facebook“未发现广告”

转载 作者:行者123 更新时间:2023-11-29 18:36:33 26 4
gpt4 key购买 nike

我想了解为什么我会收到“未找到广告”错误消息。

预计

来自 Facebook Audience Network (FAN) 的原生广告将在 Android RecyclerView Feed 中展示,其方式与下面屏幕截图中测试广告单元的展示方式相同。

enter image description here

设置

安卓

我已经关注了 Android setup对于原生广告。该应用尚未在 Play 商店上架,因为它仍在测试中。

AndroidManifest.xml

...
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="[app-package-here]">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name="[app-package-here].MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.mopub.common.privacy.ConsentDialogActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
</application>

</manifest>

network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system"/>
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
<domain includeSubdomains="true">example.com</domain>
<domain includeSubdomains="true">cdn.example2.com</domain>
</domain-config>
</network-security-config>

build.gradle(模块)

implementation('com.mopub:mopub-sdk-native-static:5.4.1@aar') {
transitive = true
}
implementation 'com.facebook.android:audience-network-sdk:5.1.0'
implementation 'com.mopub.mediation:facebookaudiencenetwork:5.1.0.0'

build.gradle(应用程序)

buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09"
}
}

allprojects {
repositories {
google()
jcenter()
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}

主 Activity

    val sdkConfiguration = SdkConfiguration.Builder([ad-unit-id-here])
.build()
MoPub.initializeSdk(this, sdkConfiguration, initSdkListener())

Activity/fragment

private fun populateAdapterType() {
moPubAdapter = MoPubRecyclerAdapter(activity!!, adapter,
MoPubNativeAdPositioning.MoPubServerPositioning())
val moPubStaticNativeAdRenderer = MoPubStaticNativeAdRenderer(
ViewBinder.Builder(R.layout.native_ad_list_item)
.titleId(R.id.native_title)
.textId(R.id.native_text)
.mainImageId(R.id.native_main_image)
.iconImageId(R.id.native_icon_image)
.callToActionId(R.id.native_cta)
.privacyInformationIconImageId(R.id.native_privacy_information_icon_image)
.build()
)
moPubAdapter.registerAdRenderer(moPubStaticNativeAdRenderer)
contentRecyclerView.adapter = moPubAdapter
moPubAdapter.loadAds([ad-unit-id-here])
}

MoPub 控制台

应用

enter image description here

广告单元

enter image description here

网络

enter image description here

fragment

enter image description here

实际

测试广告单元 ID 11a17b188668469fb0412708c3d16813 显示成功。但是,使用在 MoPub 控制台中创建的广告单元 ID 时,不会显示实时 Facebook 广告。

错误:“MoPubNetworkError:找不到广告单元的广告”

完全错误

2019-01-11 18:46:12.312 29624-29624/[app-package-here] D/MoPub: MoPubNative Loading ad from: https://ads.mopub.com/m/ad?id=[ad-id-here]&nv=5.4.1&dn=Google%2CPixel%202%2Cwalleye&bundle=[app-package-here]&z=-0800&o=p&w=1080&h=1920&sc=2.625&mcc=310&mnc=260&cn=Google%20Fi&ct=2&av=0.15&udid=mp_tmpl_advertising_id&dnt=mp_tmpl_do_not_track&gdpr_applies=0&force_gdpr_applies=0&current_consent_status=unknown&MAGIC_NO=0

2019-01-11 18:46:12.689 29624-29624/[app-package-here] D/MoPub: Attempting to invoke custom event: com.mopub.nativeads.FacebookNative

2019-01-11 18:46:13.114 29624-29624/[app-package-here] D/MoPub: Successfully hit tracking endpoint: https://ads.mopub.com/m/attempt

2019-01-11 18:46:13.205 29624-29624/[app-package-here] W/MoPub: MoPubNative.onNativeAdLoaded com.mopub.nativeads.CustomEventNativeAdapter@708f83c

2019-01-11 18:46:13.206 29624-29624/[app-package-here] V/MoPub: Native Ad failed to load with error: A required renderer was not registered for the CustomEventNative..

2019-01-11 18:46:13.394 29624-29624/[app-package-here] D/MoPub: Native ad request failed.

com.mopub.network.MoPubNetworkError: No ads found for ad unit.

at com.mopub.network.MultiAdResponse.(MultiAdResponse.java:157)

at com.mopub.network.MultiAdRequest.parseNetworkResponse(MultiAdRequest.java:96)

at com.mopub.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132)

at com.mopub.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)

可能的解决方案

  1. Placement ID:在 MoPub 中,Facebook 作为网络添加,但添加了错误的placement id。我已经使用 Facebook 的货币化管理器在 Business Manager 下生成的展示位置 ID 进行了更新。工具。

使用正确的展示位置 ID,Facebook Ad Request Debugger正在显示 MoPub 发出的请求。

Facebook 货币化经理

enter image description here

MoPub 网络设置> 应用和广告单元设置

enter image description here

Facebook 广告请求调试器

enter image description here

  1. 应用未上线:目前该应用处于测试模式,因此未在 Play 商店上线。但是,根据 Facebook 的文档,在添加支付信息之前,您的应用将无法接收 Audience Network 广告。支付信息已添加,但 Facebook 的文档未指定应用是否必须上线以及接收广告。

我还根据 Facebook's testing documentation 添加了带有我手机的 AAID 的测试设备所以不在 Play 商店上线应该不是问题。

最佳答案

在 MoPub 下 Integrating 3rd Party Ad Networks它解释了一个独特的 Ad Renderer除了使用 specific Facebook layout 之外,Facebook 还需要.

FacebookAdRenderer facebookAdRenderer = new FacebookAdRenderer(
new FacebookAdRenderer.FacebookViewBinder.Builder(R.layout.native_ad_list_item)
.titleId(R.id.native_title)
.textId(R.id.native_text)
// Binding to new layouts from Facebook 4.99.0+
.mediaViewId(R.id.native_main_image)
.adIconViewId(R.id.native_icon_image)
.adChoicesRelativeLayoutId(R.id.native_ad_choices_relative_layout)
.advertiserNameId(R.id.native_title) // Bind either the titleId or advertiserNameId depending on the FB SDK version
// End of binding to new layouts
.callToActionId(R.id.native_cta)
.build());

To know which specific layout elements to use in your XML for the MediaView, AdIconView, and AdChoices RelativeLayout in the FacebookViewBinder, please reference this sample XML layout. Additionally, depending on the Facebook SDK version you are integrating, you will need to show only either the ad title or the advertiser name. For more information about Facebook’s implementation requriements, check out this article.

Then, register your ad renderers, like below. Your classThatRegistersAdRenderers varies depending on which native ad integration you are using. Remember to register your MoPubStaticNativeAdRenderer instance last.

// MoPubRecyclerAdapter
MoPubRecyclerAdapter classThatRegistersAdRenderers = new MoPubRecyclerAdapter(...);

// MoPubStreamAdPlacer
MoPubStreamAdPlacer classThatRegistersAdRenderers = new MoPubStreamAdPlacer(...);

// MoPubAdAdapter
MoPubAdAdapter classThatRegistersAdRenderers = new MoPubAdAdapter(...);

// MoPubNative
MoPubNative classThatRegistersAdRenderers = new MoPubNative(...);

classThatRegistersAdRenderers.registerAdRenderer(
googlePlayServicesAdRenderer);

classThatRegistersAdRenderers.registerAdRenderer(
flurryNativeAdRenderer);

classThatRegistersAdRenderers.registerAdRenderer(facebookAdRenderer);

classThatRegistersAdRenderers.registerAdRenderer(staticAdRender);

关于android - MoPub 原生广告和 Facebook“未发现广告”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54153324/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com