微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

设置奖励视频监听器时,Android C ++应用程序崩溃

如何解决设置奖励视频监听器时,Android C ++应用程序崩溃

我正在使用以下代码将AdMob奖励添加到我的C ++ android应用中:

class RewardedVideoListener: public firebase::admob::rewarded_video::Listener {
public:
    //RewardedVideoListener() {}
    //RewardedVideoListener(FirebaseScene* scene) : scene(scene) {}
    void OnRewarded(firebase::admob::rewarded_video::RewardItem reward) override {
        //::LogMessage("Rewarding user with %f %s.",reward.amount,reward.reward_type.c_str());
        int a = 1;
    }
    void OnPresentationStateChanged(firebase::admob::rewarded_video::PresentationState state) override {
        int b = 1;
    }
};


static void OnRewardVideoInited(const firebase::Future<void>& future) {
    namespace rewarded_video = firebase::admob::rewarded_video;
    if (future.error() == firebase::admob::kAdMobErrorNone) {
        RewardedVideoListener rewarded_listener;
        rewarded_video::SetListener(&rewarded_listener);

        firebase::admob::AdRequest request = GetRequest();
        rewarded_video::LoadAd(krewardedvideoadUnit,request);
        rewarded_video::LoadAdLastResult().OnCompletion(OnRewardVideoLoaded);
    }
}


int AdMobC::showBanner() {
    firebase::ApP* app;
    app = ::firebase::App::Create(Getjnienv(),GetActivity());
    firebase::admob::Initialize(*app,kAdMobAppID);

    // Start up rewarded video ads and associated mediation adapters.
    namespace rewarded_video = firebase::admob::rewarded_video;
    rewarded_video::Initialize();
    rewarded_video::InitializeLastResult().OnCompletion(OnRewardVideoInited);

    return 1;
}

每当我添加以下行时:

RewardedVideoListener rewarded_listener;
rewarded_video::SetListener(&rewarded_listener);

我得到'A / libc:致命信号11(SIGSEGV),代码1(SEGV_MAPERR),故障TID 18423(adarts.fuelhunt),pid 18423(adarts.fuelhunt)中的故障加法器0x8'

我想知道我做错了什么吗?我已经有一段时间没有使用C ++了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。