简体   繁体   English

无法使用Mopub在Android中通过手动集成来实施本地视频广告

[英]Not able to implement Native Video ads through Manual Integration in android using Mopub

As the Documentation of Mopub say's here ,integrated the Native ads and followed by Native Video ads. 作为Mopub的文档说的这里 ,集成原生广告,并随后本地视频广告。

After integrating the code the ad request response is calling the callback method onNativeFail() with some of the response 集成代码后,广告请求响应将使用某些响应调用回调方法onNativeFail()

Below code is related to the workflow and logcat message 以下代码与工作流程和logcat消息相关

public class MainActivity extends Activity { 公共类MainActivity扩展了Activity {

private MoPubView moPubView;
//private MoPubInterstitial mInterstitial;
private MoPubNative moPubNative;
private MoPubNativeNetworkListener moPubNativeNetworkListener;
private NativeAd.MoPubNativeEventListener moPubNativeEventListener;
AdapterHelper adapterHelper;
private NativeFullScreenVideoView nativeFullScreenVideoView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    moPubNativeNetworkListener = new MoPubNativeNetworkListener() {
        @Override
        public void onNativeLoad(NativeAd nativeAd) {
            Log.d("MoPub", "Native ad has loaded.");

        }

        @Override
        public void onNativeFail(NativeErrorCode errorCode) {
            Log.d("MoPub", "Native ad failed to load with error: " + errorCode.toString());
        }
    };

    moPubNativeEventListener = new NativeAd.MoPubNativeEventListener() {
        @Override
        public void onImpression(View view) {
            Log.d("MoPub", "Native ad recorded an impression.");
            // Impress is recorded - do what is needed AFTER the ad is visibly shown here.
        }

        @Override
        public void onClick(View view) {
            Log.d("MoPub", "Native ad recorded a click.");
            // Click tracking.
        }
    };

    moPubNative = new MoPubNative(this, "02a2d288d2674ad09f3241d46a44356e ", moPubNativeNetworkListener);

    ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_ad_list_item)
            .mainImageId(R.id.native_main_image)
            .iconImageId(R.id.native_icon_image)
            .titleId(R.id.native_title)
            .textId(R.id.native_text)
            .privacyInformationIconImageId(R.id.native_privacy_information_icon_image)
            .build();


    MediaViewBinder mediaViewBinder = new MediaViewBinder.Builder(R.layout.native_video_ad_layout)
            .mediaLayoutId(R.id.native_ad_video_view)
            .iconImageId(R.id.native_ad_icon_image)
            .titleId(R.id.native_ad_title)
            .textId(R.id.native_ad_text)
            .build();

    MoPubVideoNativeAdRenderer moPubVideoNativeAdRenderer = new MoPubVideoNativeAdRenderer(mediaViewBinder);
    moPubNative.registerAdRenderer(moPubVideoNativeAdRenderer);


    MoPubStaticNativeAdRenderer moPubStaticNativeAdRenderer = new MoPubStaticNativeAdRenderer(viewBinder);
    moPubNative.registerAdRenderer(moPubStaticNativeAdRenderer);


    EnumSet<RequestParameters.NativeAdAsset> desiredAssets = EnumSet.of(
            RequestParameters.NativeAdAsset.TITLE,
            RequestParameters.NativeAdAsset.TEXT,
            RequestParameters.NativeAdAsset.CALL_TO_ACTION_TEXT,
            RequestParameters.NativeAdAsset.MAIN_IMAGE,
            RequestParameters.NativeAdAsset.ICON_IMAGE,
            RequestParameters.NativeAdAsset.STAR_RATING
    );

    RequestParameters mRequestParameters = new RequestParameters.Builder()
            .desiredAssets(desiredAssets)
            .build();

    moPubNative.makeRequest();

}

} }

After running this code, the ad is not getting loaded and the response of my code is below 运行此代码后,广告未加载,我的代码的响应如下

06-06 17:01:41.797 24421-24421/? I/Ads: Webview loading for native ads.
06-06 17:01:41.911 24421-24421/? I/Ads: Javascript has loaded for native ads.
06-06 17:02:18.623 24421-24421/? I/Ads: Webview loading for native ads.
06-06 17:02:18.954 24421-24421/? I/Ads: Javascript has loaded for native ads.
06-06 17:02:51.796 13278-13278/com.fabgrad.students.android D/MoPub: Native ad request failed.
                                                                 com.mopub.network.MoPubNetworkError: No ads found for ad unit.
                                                                     at com.mopub.network.AdRequest.parseNetworkResponse(AdRequest.java:180)
                                                                     at com.mopub.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132)
                                                                     at com.mopub.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)
06-06 17:02:51.800 13278-13278/com.fabgrad.students.android D/MoPub: Native ad failed to load with error: Server returned empty response.

As per their blog, No ads found will come for following scenarios: 根据他们的博客,在以下情况下找不到广告:

These errors indicate that there was no fill for your ad unit. 这些错误表明您的广告单元没有足够的广告空间。 No ad network will have fill 100% of the time, so seeing this log is normal. 没有广告网络会在100%的时间内充满广告,因此看到此日志是正常的。 New apps and apps with very low volume tend to experience lower fill rates. 新应用程序和体积很小的应用程序的填充率往往较低。 Contact your ad network representative if you have any concerns related to a particular network's fill. 如果您对特定广告网络的填充有任何疑问,请与您的广告网络代表联系。

If you are consistently seeing no fill, review your ad network placement details in the Networks tab of the MoPub UI, as well as your settings in the Network's UI. 如果您始终看不到填充,请在MoPub UI的“网络”标签中查看您的广告网络展示位置详细信息,并在“网络” UI中查看您的设置。

You won't be able to show ads from Certified Ad Networks if you forgot to include the network SDK or adapter files. 如果您忘记包含网络SDK或适配器文件,则将无法展示来自认证广告网络的广告。 The Couldn't locate or instantiate custom event and Unable to find Native Network or Custom Event adapter log messages are indicators that the network SDK or adapter file is missing, renamed, or in the wrong location. “无法找到或实例化自定义事件”和“找不到本机网络”或“自定义事件”适配器日志消息是网络SDK或适配器文件丢失,重命名或位置错误的指示。

Review our Integrating Third-Party Ad Networks documentation to resolve this. 查看我们的集成第三方广告网络文档以解决此问题。

Link for reference. 链接以供参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM