当Android应用程序在发布模式下构建时,InMobi插页式广告未加载,错误代码"无法呈现广告"

时间:2015-07-05 03:46:49

标签: android ads inmobi

我已将inmobi sdk与Android应用集成,测试模式工作正常,即使我在非测试设备上安装调试版本应用广告也正确呈现。

只有在我发布版本时才会出现问题。

主要活动代码

public class Wh_MainActivity extends ActionBarActivity {

IMInterstitial mInmobiInterstitialAd=null;
private Wh_InMobiInterstitial_AdListener mInMobiIntAd_Listener;

}

简历我正在创建此插页式广告

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

并设置以下监听器

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");
    }
 }
};

我在后退按钮上加载广告,我在IMInterstitialListener onInterstitialFailed(IMInterstitial arg0,IMErrorCode eCode)中收到错误IMErrorCode =&#34;无法呈现广告“&#34;

我使用Android工具 - >导出签名应用程序包选项

在Eclipse中创建签名应用程序

1 个答案:

答案 0 :(得分:1)

问题与progaurd有关。如果我不在发布版本中应用progaurd,则广告正确无误。 以下行需要添加progaurd配置文件 -keep class com.inmobi。** {*; } -dontwarn com.inmobi。**