Android ,problems with displaying, error 'Server returned empty response '

mopub
android
sdk
java

#1

Hi guys, i have a problem when i request an advertisement sends me an error 'Server returned empty response '.
So always except the very first time, if you uninstall and install the application
The implementation is simple, what can be the error ???

   MoPubNative.MoPubNativeNetworkListener moPubNativeListener = new MoPubNative.MoPubNativeNetworkListener() {
                @Override
                public void onNativeLoad(NativeAd nativeAd) {

                    View adViewRender = nativeAd.createAdView(context, container);
                    nativeAd.renderAdView(adViewRender);
                    nativeAd.prepare(adViewRender);
                    container.addView(adViewRender);
                    pb.setVisibility(View.GONE);
                }

                @Override
                public void onNativeFail(NativeErrorCode errorCode) {
                    Log.d("LockUpMopub", errorCode + " errorcode");
                    entities.remove(entity);
                    notifyDataSetChanged();
                }
            };

            MoPubNative mMoPubNative = new MoPubNative(context
                    , entity.getAndroidId(), moPubNativeListener);

            ViewBinder viewBinder = new ViewBinder.Builder(R.layout.item_mopub)
                    .mainImageId(R.id.image)
                    .iconImageId(R.id.native_ad_daa_icon_image)
                    .build();

            MoPubStaticNativeAdRenderer adRenderer = new MoPubStaticNativeAdRenderer(viewBinder);

            mMoPubNative.registerAdRenderer(adRenderer);
            mMoPubNative.makeRequest();

#2

Hi, I am facing same issue. Did you find solution? Thanks!


#3

Hi, yes, i discussed this problem with support:

"After reviewing your account we noticed that you currently have a daily
frequency capping enabled on the Ad Unit
-----------------------------------------. The frequency cap of 1
impression per user per day would be a reason why you see “Server returned
empty response”. To disable/ edit this setting please navigate to the Ad
Unit page then select “Edit Ad Unit Settings” (ss attached below). If the
issue persists even after you removed the frequency cap, please reach back
out to us with the device logs (send over as an attachment) since we do
not do code reviews.

[image: User-added image]"


#4

This option is unchecked but still getting this logcat:

Native ad request failed.

com.mopub.network.MoPubNetworkError: No ads found for ad unit.
at
com.mopub.network.AdRequest.parseNetworkResponse(AdRequest.java:139)
at
com.mopub.volley.NetworkDispatcher.run(NetworkDispatcher.java:123)
07-17 17:12:39.494 28040-28040/mopub.com.mopub D/LockUpMopub: Server
returned empty response. errorcode

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Virus-free.
www.avast.com
https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


#5

can you send me your code ?


#6
 void initAds() {
        MoPubNative.MoPubNativeNetworkListener moPubNativeListener = new MoPubNative.MoPubNativeNetworkListener() {
            @Override
            public void onNativeLoad(NativeAd nativeAd) {

                View adViewRender = nativeAd.createAdView(getApplicationContext(), ((FrameLayout) findViewById(R.id.flAd)));
                nativeAd.renderAdView(adViewRender);
                nativeAd.prepare(adViewRender);
            }

            @Override
            public void onNativeFail(NativeErrorCode errorCode) {
                Log.d("LockUpMopub", errorCode + " errorcode");
            }
        };

        MoPubNative mMoPubNative = new MoPubNative(getApplicationContext()
                , getResources().getString(R.string.activity_ad_unit_id), moPubNativeListener);

        ViewBinder viewBinder = new ViewBinder.Builder(R.layout.native_ad_list_item)
                .mainImageId(R.id.native_ad_main_image)
                .iconImageId(R.id.native_ad_icon_image)
                .titleId(R.id.native_ad_title)
                .textId(R.id.native_ad_text)
                .callToActionId(R.id.native_ad_call_to_action)
                .build();

        MoPubStaticNativeAdRenderer adRenderer = new MoPubStaticNativeAdRenderer(viewBinder);

        mMoPubNative.registerAdRenderer(adRenderer);
        mMoPubNative.makeRequest();
    }

#7

*you should make as(the work solution): *

public void bind() {
try {
pb.setVisibility(View.VISIBLE);

    ViewBinder viewBinder = new ViewBinder.Builder(R.layout.item_mopub)
            .mainImageId(R.id.image)
            .iconImageId(R.id.native_ad_daa_icon_image)
            .build();

    MoPubNative.MoPubNativeNetworkListener moPubNativeListener =

new MoPubNative.MoPubNativeNetworkListener() {
@Override
public void onNativeLoad(NativeAd nativeAd) {
try {
View adViewRender = nativeAd.createAdView(context,
container);
nativeAd.renderAdView(adViewRender);
nativeAd.prepare(adViewRender);
container.addView(adViewRender);
pb.setVisibility(View.GONE);
} catch (IllegalStateException ex) {
Log.e(“err”, "onNativeLoad: " + ex.getMessage());
}
}

        @Override
        public void onNativeFail(NativeErrorCode errorCode) {
            Log.d("LockUpMopub", errorCode + " errorcode");
            entities.remove(entity);
            notifyDataSetChanged();
        }
    };

    MoPubNative mMoPubNative = new MoPubNative(context
            , entity.getAndroidId(), moPubNativeListener);
    MoPubStaticNativeAdRenderer adRenderer = new

MoPubStaticNativeAdRenderer(viewBinder);

    mMoPubNative.registerAdRenderer(adRenderer);
    mMoPubNative.makeRequest();
} catch (Exception ex) {
    pb.setVisibility(View.GONE);
    container.setVisibility(View.GONE);
    Log.e("err", "bind: " + ex.getMessage());
}

}


#8

What is the difference between your code and mine? Both are same.


#9

i think in setting account admob