Amit Deshmukh
Amit Deshmukh

Reputation: 13

InMobi interstitial ads are not loading when android app is build in release mode,error code "Failed to render ad"

I have integrated inmobi sdk with android app, test mode is working fine, even when I installed debug build app on non test device ads are getting rendered correctly.

Problem occurs only when I do release build.

Main activity code

public class Wh_MainActivity extends ActionBarActivity {

IMInterstitial mInmobiInterstitialAd=null;
private Wh_InMobiInterstitial_AdListener mInMobiIntAd_Listener;

}

on resume I am creating this interstitial ads

    protected void onResume() {
        mInmobiInterstitialAd = new IMInterstitial(this,appId);
        mInmobiInterstitialAd.loadInterstitial();
        mInMobiIntAd_Listener=  new Wh_InMobiInterstitial_AdListener(this);
        mInmobiInterstitialAd.setIMInterstitialListener(mInMobiIntAd_Listener);
    }

and setting up the following listener to it

import java.util.Map;
import android.content.Context;
import android.widget.Toast;
import com.inmobi.monetization.IMErrorCode;
import com.inmobi.monetization.IMInterstitial;
import com.inmobi.monetization.IMInterstitialListener;

class Wh_InMobiInterstitial_AdListener implements  IMInterstitialListener {
    private Wh_MainActivity RefMainActPassed = null;

public Wh_InMobiInterstitial_AdListener(Wh_MainActivity refMainActPassed) {
    super();
    RefMainActPassed = refMainActPassed;
}

@Override
public void onLeaveApplication(IMInterstitial arg0) {
    //handler.sendEmptyMessage(ON_LEAVE_APP);       
    Wh_GoogleAnalyticsTrackerLogger gaTracker=((Wh_App)RefMainActPassed.getApplication()).getGATrackerLogger();
    if(gaTracker!=null)
    {
        gaTracker.sendEvent(Wh_GAEventMsg.INMOBI_Ad_CAT, Wh_GAEventMsg.InMobi_LeaveApplication, 0, "label");
    }
}
@Override
public void onDismissInterstitialScreen(IMInterstitial arg0) {
    //handler.sendEmptyMessage(ON_DISMISS_MODAL_AD);
    Wh_GoogleAnalyticsTrackerLogger gaTracker=((Wh_App)RefMainActPassed.getApplication()).getGATrackerLogger();
    if(gaTracker!=null)
    {
        gaTracker.sendEvent(Wh_GAEventMsg.INMOBI_Ad_CAT, Wh_GAEventMsg.InMobi_DismissInterstitialScreen, 0, "label");
    }
}

@Override
public void onInterstitialFailed(IMInterstitial arg0, IMErrorCode eCode) {

    String ERRORCODE=   eCode.toString();
        Wh_GoogleAnalyticsTrackerLogger gaTracker=((Wh_App)RefMainActPassed.getApplication()).getGATrackerLogger();
    if(gaTracker!=null)
    {
        gaTracker.sendEvent(Wh_GAEventMsg.INMOBI_Ad_CAT, Wh_GAEventMsg.InMobi_InterstitialFailed, 0, ERRORCODE);
    }

    Context context = RefMainActPassed.getApplicationContext();
    CharSequence text = "FAILED WITH err code " +ERRORCODE ;
    int duration = Toast.LENGTH_LONG;

    Toast toast = Toast.makeText(context, text, duration);
    toast.show();

}

@Override
public void onInterstitialInteraction(IMInterstitial arg0,
        Map<String, String> arg1) {
    // no-op
    Wh_GoogleAnalyticsTrackerLogger gaTracker=((Wh_App)RefMainActPassed.getApplication()).getGATrackerLogger();
    if(gaTracker!=null)
    {
        gaTracker.sendEvent(Wh_GAEventMsg.INMOBI_Ad_CAT, Wh_GAEventMsg.InMobi_InterstitialInteraction, 0, "label");
    }
}

@Override
public void onInterstitialLoaded(IMInterstitial arg0) {
    //handler.sendEmptyMessage(AD_REQUEST_SUCCEEDED);   
    Wh_GoogleAnalyticsTrackerLogger gaTracker=((Wh_App)RefMainActPassed.getApplication()).getGATrackerLogger();
    if(gaTracker!=null)
    {
        gaTracker.sendEvent(Wh_GAEventMsg.INMOBI_Ad_CAT, Wh_GAEventMsg.InMobi_InterstitialLoaded, 0, "label");
    }


    Context context = RefMainActPassed.getApplicationContext();
    CharSequence text = "Inmobi Ad loaded"  ;
    int duration = Toast.LENGTH_LONG;

    Toast toast = Toast.makeText(context, text, duration);
    toast.show();

}

@Override
public void onShowInterstitialScreen(IMInterstitial arg0) {
    //handler.sendEmptyMessage(ON_SHOW_MODAL_AD);   
    Wh_GoogleAnalyticsTrackerLogger gaTracker=((Wh_App)RefMainActPassed.getApplication()).getGATrackerLogger();
    if(gaTracker!=null)
    {
        gaTracker.sendEvent(Wh_GAEventMsg.INMOBI_Ad_CAT,      Wh_GAEventMsg.InMobi_ShowInterstitialScreen, 0, "label");
    }
 }
};

I am loading ad at back button press,I am getting error in IMInterstitialListener onInterstitialFailed (IMInterstitial arg0, IMErrorCode eCode) IMErrorCode="Failed to render ad”"

I am creating signed application in Eclipse by using Android Tools->Export Signed Application Package option

Upvotes: 0

Views: 558

Answers (1)

Amit Deshmukh
Amit Deshmukh

Reputation: 13

Issue is related to progaurd. When I don't apply progaurd in release build ads are getting correctly. Following lines need to be added progaurd config file -keep class com.inmobi.** { *; } -dontwarn com.inmobi.**

Upvotes: 1

Related Questions