cocos2d-x / firebase / admob无法加载插页式广告

时间:2017-12-24 07:05:02

标签: java android firebase admob cocos2d-x

我正在按照此官方指南将firebase / admob集成到我的cocos2d-x项目中。

https://firebase.google.com/docs/admob/cpp/quick-start

这是我的代码:

void Helper::initializeAdmob() {

    // Initialize Firebase for Android.
    firebase::App* app = firebase::App::Create(firebase::AppOptions(), JniHelper::getEnv(), JniHelper::getActivity());
    // Initialize AdMob.
    firebase::admob::Initialize(*app, admob_app_id);
    firebase::admob::Initialize(*app);

    interstitial_ad = new firebase::admob::InterstitialAd();
    interstitial_ad->Initialize(static_cast<firebase::admob::AdParent>(getAdParent()), testing_boolean ? interstitial_id_for_testing : interstitial_id);

}

void Helper::requestInterstitialAd() {

    if (interstitial_ad->InitializeLastResult().status() == firebase::kFutureStatusComplete && interstitial_ad->InitializeLastResult().error() == firebase::admob::kAdMobErrorNone) {
        firebase::admob::AdRequest request = {};
        const char* myKindleFireDeviceId = "7E9D27D370EA69CD2B962EE957B1C198";
        static const char* testDevices[] = {myKindleFireDeviceId};
        request.test_device_ids = testDevices;
        request.test_device_id_count = sizeof(testDevices) / sizeof(testDevices[0]);
        interstitial_ad->LoadAd(request);
    }

}

void Helper::showInterstitialAd() {
    if (interstitial_ad->LoadAdLastResult().status() == firebase::kFutureStatusComplete && interstitial_ad->LoadAdLastResult().error() == firebase::admob::kAdMobErrorNone) {
        interstitial_ad->Show();
    }
}

initializeAdmob()被执行得很好。 然后对于requestInterstitialAd(),我得到了400错误:

12-23 22:57:28.743 24354-25845/com.xx.xx W/Ads: Received error HTTP response code: 400
12-23 22:57:28.756 24354-25845/com.xx.xx W/Ads: There was a problem getting an ad response. ErrorCode: 0
12-23 22:57:28.759 24354-24354/com.xx.xx W/Ads: Failed to load ad: 0

编辑:

我正在使用点燃火。

编辑2:

我的点燃火与互联网有关。

编辑3:

我使用的是我自己的admob app id,以及android插页式广告的测试ID

编辑4:

我尝试过横幅广告并获得相同的结果。 我也试过模拟器和相同的结果。

1 个答案:

答案 0 :(得分:1)

您可以尝试使用Play商店的任何设备吗?在Admob停止提供独立SDK之后,Kindle Fire曾经为我工作但不再适用。