0

我已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="Failed to render ad""

我正在使用 Android Tools->Export Signed Application Package 选项在 Eclipse 中创建签名应用程序

4

1 回答 1

1

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

于 2015-07-07T15:33:54.377 回答