In general, it's working fine. I've implemented the reward to try to load an ad until it has one ready for the user to watch.
When the phone running the app loses connection to the internet, it keeps going on and on, and as far as I can tell, that doesn't generate any error.
The problem is when I keep pressing repeatedly the back button on the android phone, that's when the app crashes.
inline void FutureBase::Release() {
if (api_ != NULL) { // NOLINT
api_->ReleaseFuture(handle_); <------- on this line
api_ = NULL; // NOLINT
}
}
Callstack:
tgkill
pthread_kill
raise
__libc_android_abort
abort
firebase::DefaultLogCallback(firebase::LogLevel, const char *, void *)
firebase::LogMessageWithCallbackV(firebase::LogLevel, const char *, va_list)
firebase::LogAssert(char const*, ...)
firebase::ReferenceCountedFutureImpl::CompleteHandle(unsigned int)
firebase::FutureBase::Release() future_impl.h:111
firebase::ReferenceCountedFutureImpl::CompleteHandle(unsigned int)
firebase::ReferenceCountedFutureImpl::CompleteHandle(unsigned int)
firebase::admob::(anonymous)(JNIEnv *, jlong, jint, jstring, jclass)
This is the log:
1 - D/cocos2d-x debug info: reinitRewardedVideoAd
2 - D/Cocos2dxActivity: onWindowFocusChanged() hasFocus=false
3 - W/firebase: Future with handle 3 still exists though its backing API 0xB74F7E64 is being deleted. Please call Future::Release() before deleting the backing API.
4 - D/cocos2d-x debug info: initRewardedVideoAd
5 - E/firebase: firebase::App __FIRAPP_DEFAULT already created, options will not be applied.
6 - W/firebase: AdMob is already initialized.
7 - A/firebase: it != backings_.end()
It's probably related to the 3rd line (which is probably related to the last line), because that's the api_ variable address and the handle_ value when it crashed.
Here's my code:
static void initRewardedVideoAd()
{
log("initRewardedVideoAd");
isRewardedAdInitialized=false;
#if IS_ANDROID()
// Initialize Firebase for Android.
firebase::App *app=firebase::App::Create(cocos2d::JniHelper::getEnv(), cocos2d::JniHelper::getActivity());
firebase::admob::Initialize(*app, "INSERT_YOUR_ADMOB_ANDROID_APP_ID");
#endif//IS_ANDROID()
firebase::admob::rewarded_video::Initialize();
firebase::admob::rewarded_video::InitializeLastResult().OnCompletion(onRewardedVideoInitializeCompletionCallback, SCENE_SELF);
}
static void reinitRewardedVideoAd()
{
log("reinitRewardedVideoAd");
firebase::admob::rewarded_video::Destroy();
initRewardedVideoAd();
}
Should I do something before Destroy()? Or maybe there's another way of doing it without calling Destroy()?
Felipe.