Firebase AdMob - can't play rewarded video

144 views
Skip to first unread message

Andrei Lazutin

unread,
Oct 4, 2018, 11:51:42 AM10/4/18
to google-adm...@googlegroups.com
I use latest Firebase AdMob SDK C++, integrate via pods as described. Exactly same code on Android - works fine.
If I try to play rewarded video (from my ID or TestID) I get error:

<Google> Invalid Request. Cannot determine request type. Is your ad unit id correct?

I checked everything twice, all libs, all integration, all keys ... all looks good on my side.
firebase::admob::Initialize - returns OK.
rewarded_video::LoadAd - FAILED (Request object configured wrong)

But same happens for TestID.

Can someone check what is wrong with latest c++ SDK?

I'm on latest iOS 12.

mobileadssdk-a...@google.com

unread,
Oct 4, 2018, 4:07:51 PM10/4/18
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hello Andrei, 

Thank you for contacting us and making sure to delete the sensitive information. I was able to load the Rewarded video ads on iOS without any issues with this Ad Unit ID. Can you make sure that you defined the iOS and Android Ad Unit IDs respectively? Could you please share the code snippets of your implementation so I can take a look? 

Regards,
Bharani Cherukuri
Mobile Ads SDK Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 10/04/18 11:51:42 mrpu...@gmail.com wrote:
I use latest Firebase AdMob SDK, integrate via pods as described. Exactly same code on Android - works fine.
If I try to play rewarded video (from my ID or TestID) I get error:

<Google> Invalid Request. Cannot determine request type. Is your ad unit id correct?

I checked everything twice, all libs, all integration, all keys ... all looks good on my side.

Can someone check what is wrong while playing ca-app-pub-9449884827883209/3407149084 ? For me it looks like some glitch on Firebase side.

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/2d480d8b-2ab3-4398-b9fc-ad001d03fc52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrei Lazutin

unread,
Oct 5, 2018, 12:23:30 AM10/5/18
to mobileadssdk-a...@google.com, google-adm...@googlegroups.com
I use latest Firebase AdMob SDK C++, integrate via pods as described. Exactly same code on Android - works fine.
If I try to play rewarded video (from my ID or TestID) I get error:

<Google> Invalid Request. Cannot determine request type. Is your ad unit id correct?

I checked everything twice, all libs, all integration, all keys ... all looks good on my side.
firebase::admob::Initialize - returns OK.
rewarded_video::LoadAd - FAILED (Request object configured wrong)

But same happens for TestID.

Can someone check what is wrong with latest c++ SDK?

I'm on latest iOS 12.
On Thu, Oct 4, 2018 at 11:07 PM <mobileadssdk-a...@google.com> wrote:
Hello Andrei, 

Thank you for contacting us and making sure to delete the sensitive information. I was able to load the Rewarded video ads on iOS without any issues with this Ad Unit ID. Can you make sure that you defined the iOS and Android Ad Unit IDs respectively? Could you please share the code snippets of your implementation so I can take a look? 

Regards,
Bharani Cherukuri
Mobile Ads SDK Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 10/04/18 11:51:42 mrpu...@gmail.com wrote:
I use latest Firebase AdMob SDK, integrate via pods as described. Exactly same code on Android - works fine.
If I try to play rewarded video (from my ID or TestID) I get error:

<Google> Invalid Request. Cannot determine request type. Is your ad unit id correct?

I checked everything twice, all libs, all integration, all keys ... all looks good on my side.

Can someone check what is wrong while playing ca-app-pub-9449884827883209/3407149084 ? For me it looks like some glitch on Firebase side.

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
To post to this group, send email to google-adm...@googlegroups.com.

Andrei Lazutin

unread,
Oct 5, 2018, 1:31:01 AM10/5/18
to Google Mobile Ads SDK Developers
Actually I follow this steps


And it fails on LoadAd without any reason.

On Friday, October 5, 2018 at 7:23:30 AM UTC+3, Andrei Lazutin wrote:
I use latest Firebase AdMob SDK C++, integrate via pods as described. Exactly same code on Android - works fine.
If I try to play rewarded video (from my ID or TestID) I get error:

<Google> Invalid Request. Cannot determine request type. Is your ad unit id correct?

I checked everything twice, all libs, all integration, all keys ... all looks good on my side.
firebase::admob::Initialize - returns OK.
rewarded_video::LoadAd - FAILED (Request object configured wrong)

But same happens for TestID.

Can someone check what is wrong with latest c++ SDK?

I'm on latest iOS 12.

On Thu, Oct 4, 2018 at 11:07 PM <mobileadssdk-advisor+support@google.com> wrote:
Hello Andrei, 

Thank you for contacting us and making sure to delete the sensitive information. I was able to load the Rewarded video ads on iOS without any issues with this Ad Unit ID. Can you make sure that you defined the iOS and Android Ad Unit IDs respectively? Could you please share the code snippets of your implementation so I can take a look? 

Regards,
Bharani Cherukuri
Mobile Ads SDK Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 10/04/18 11:51:42 mrpu...@gmail.com wrote:
I use latest Firebase AdMob SDK, integrate via pods as described. Exactly same code on Android - works fine.
If I try to play rewarded video (from my ID or TestID) I get error:

<Google> Invalid Request. Cannot determine request type. Is your ad unit id correct?

I checked everything twice, all libs, all integration, all keys ... all looks good on my side.

Can someone check what is wrong while playing ca-app-pub-9449884827883209/3407149084 ? For me it looks like some glitch on Firebase side.

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

mobileadssdk-a...@google.com

unread,
Oct 5, 2018, 3:12:44 PM10/5/18
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hello Andrei, 

It is possible that you're using the Android implementation to load iOS ads which might be causing the issue. Could you please share the code snippets of your implementation so I can take a look? 

Thanks,
Bharani Cherukuri
Mobile Ads SDK Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

Andrei Lazutin

unread,
Oct 6, 2018, 5:35:25 AM10/6/18
to Google Mobile Ads SDK Developers
I use TestAD, it it fails to show.

This is 3-5 lines of code, just follow this steps

mobileadssdk-a...@google.com

unread,
Oct 8, 2018, 8:36:32 AM10/8/18
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hi Andrei,

I'm a teammate of Bharani and I will be assisting you on this.

I tested your Rewarded Ad Unit Id on this sample Firebase C++ project and I was able to load ads successfully on my end when I build and run the iOS app. That said, could you test your Ad Unit Id with the sample project and see if you still get the same error? Just open the testapp.xcworkspace then change the kRewardedVideoAdUnit value to your Ad Unit Id in the common_main.cc file (located in testapp > src). Currently, in that sample project, the kRewardedVideoAdUnit is set to a literal string "YOUR REWARDED AD UNIT ID" so make sure to change it to your Ad Unit Id, otherwise, it will throw the "<Google> Invalid Request. Cannot determine request type. Is your ad unit id correct?" error message. 

Once you've set your Ad Unit Id and after building and running the iOS app, upon app launch, an Ad Request for the Rewarded Ad will be sent programmatically, then once the Rewarded Ad is loaded successfully, it will trigger the display of the Rewarded Ad programmatically.

Regards,
Ivan Bautista
Mobile Ads SDK Team




--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

Andrei Lazutin

unread,
Dec 28, 2018, 1:33:49 PM12/28/18
to Google Mobile Ads SDK Developers
Ok, I found a why I can't see ads. Use use sample project https://drive.google.com/file/d/1WXacRU5W3DkhA_ruv9lvRIg3mWwLfUe3/view?usp=sharing

And make small changes ...

remove line rewarded_video::LoadAd(kRewardedVideoAdUnit, request);

and replace this call with function like:

static void LoadAd(const std::string& theAdsId)
{
  static firebase::admob::AdRequest request; // NOTE: this is has to be static, or CRASH!!!
  rewarded_video::LoadAd(theAdsId.c_str(), request);
}


Looks like rewarded_video::LoadAd do not copy adsId under iOS (Android works fine here) and get garbage instead of real ID.

Can someone check this code? Is it by design? I did not see any notes on header side ...

Andrei Lazutin

unread,
Jan 2, 2019, 2:54:45 AM1/2/19
to Google Mobile Ads SDK Developers
Any ideas?

mobileadssdk-a...@google.com

unread,
Jan 2, 2019, 8:56:42 AM1/2/19
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hello Andrei, 

Thank you for sharing the sample project. It was really helpful. You will need to set the Rewarded video Test/Production Ad Unit ID for the property kRewardedVideoAdUnit. Please find the attached screenshot as a reference. You may use the Test Ad Unit Ids listed here to get started. Can you give this a try and let me know if you have any questions?

Regards,
Bharani Cherukuri
Mobile Ads SDK Team
Screen Shot 2019-01-02 at 8.51.40 AM.png

Andrei Lazutin

unread,
Jan 2, 2019, 8:58:32 AM1/2/19
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
Looks like you don't understand the trouble. See, if I set ID's from STATIC strings - all works fine. BUT if I set ID's from parameters inside function - it does not works.

mobileadssdk-a...@google.com

unread,
Jan 2, 2019, 3:45:01 PM1/2/19
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hello Andrei, 

Could you please confirm if you're setting the Ad Unit IDs in the Android or iOS platform? I was able to check the iOS project and share the details on my findings in my previous reply from the Testapp.xcworkspace. Could you point me to the class path where you're setting the Ad Unit IDs, so I can take a closer look?

Thanks,
Bharani Cherukuri
Mobile Ads SDK Team

Andrei Lazutin

unread,
Jan 2, 2019, 3:48:47 PM1/2/19
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
Once again, IT WORKS in sample project.

BUT, it works ONLY if you set ID from static variables. If you try to set it from dynamic variables, as I do it, via function call - you crash app or don't get any ads at all.

THIS NOT about show/not show ads, this is about how to design function call. 

remove line rewarded_video::LoadAd(kRewardedVideoAdUnit, request);

and replace this call with function like:

static void LoadAd(const std::string& theAdsId)
{
  static firebase::admob::AdRequest request; // NOTE: this is has to be static, or CRASH!!!
  rewarded_video::LoadAd(theAdsId.c_str(), request);
}

Did you try this changes?

Andrei Lazutin

unread,
Jan 2, 2019, 4:01:49 PM1/2/19
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
Replace common_main.cc with

// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "firebase/admob.h"
#include "firebase/admob/banner_view.h"
#include "firebase/admob/interstitial_ad.h"
#include "firebase/admob/rewarded_video.h"
#include "firebase/admob/types.h"
#include "firebase/app.h"
#include "firebase/future.h"

// Thin OS abstraction layer.
#include "main.h"  // NOLINT

// A simple listener that logs changes to rewarded video state.
class LoggingRewardedVideoListener
    : public firebase::admob::rewarded_video::Listener {
 public:
  LoggingRewardedVideoListener() {}
  void OnRewarded(firebase::admob::rewarded_video::RewardItem reward) override {
    ::LogMessage("Rewarding user with %f %s.", reward.amount,
                 reward.reward_type.c_str());
  }
  void OnPresentationStateChanged(
      firebase::admob::rewarded_video::PresentationState state) override {
    ::LogMessage("Rewarded video PresentationState has changed to %d.", state);
  }
};


const char* kAdMobAppID = "ca-app-pub-3940256099942544~1458002511";

const char* kRewardedVideoAdUnit = "YOUR REWARDED AD UNIT ID";


// Sample keywords to use in making the request.
static const char* kKeywords[] = {"AdMob", "C++", "Fun"};

// Sample test device IDs to use in making the request.
static const char* kTestDeviceIDs[] = {"2077ef9a63d2b398840261c8221a0c9b",
                                       "098fe087d987c9a878965454a65654d7"};

// Sample birthday value to use in making the request.
static const int kBirthdayDay = 10;
static const int kBirthdayMonth = 11;
static const int kBirthdayYear = 1976;

static void WaitForFutureCompletion(firebase::FutureBase future) {
  while (!ProcessEvents(1000)) {
    if (future.status() != firebase::kFutureStatusPending) {
      break;
    }
  }

  if (future.error() != firebase::admob::kAdMobErrorNone) {
    LogMessage("ERROR: Action failed with error code %d and message \"%s\".",
               future.error(), future.error_message());
  }
}

static void LoadAd1(const std::string& theAdsId)
{
  firebase::admob::AdRequest request;
  rewarded_video::LoadAd(theAdsId.c_str(), request); // CRASH under iOS
}

static void LoadAd2(const std::string& theAdsId)
{
  static firebase::admob::AdRequest request; // NOTE: this is has to be static, or CRASH!!!
  rewarded_video::LoadAd(theAdsId.c_str(), request);
}

// Execute all methods of the C++ admob API.
extern "C" int common_main(int argc, const char* argv[]) {
  firebase::App* app;
  LogMessage("Initializing the AdMob library.");

#if defined(__ANDROID__)
  app = ::firebase::App::Create(GetJniEnv(), GetActivity());
#else
  app = ::firebase::App::Create();
#endif  // defined(__ANDROID__)

  LogMessage("Created the Firebase App %x.",
             static_cast<int>(reinterpret_cast<intptr_t>(app)));

  LogMessage("Initializing the AdMob with Firebase API.");
  firebase::admob::Initialize(*app, kAdMobAppID);

  // Start up rewarded video ads and associated mediation adapters.
  LogMessage("Initializing rewarded video.");
  namespace rewarded_video = firebase::admob::rewarded_video;
  rewarded_video::Initialize();

  WaitForFutureCompletion(rewarded_video::InitializeLastResult());

  LogMessage("Setting rewarded video listener.");
  LoggingRewardedVideoListener rewarded_listener;
  rewarded_video::SetListener(&rewarded_listener);

  LogMessage("Loading a rewarded video ad.");
  //rewarded_video::LoadAd(kRewardedVideoAdUnit, request);



  ///////////////////////////////////////////////////////////////////
  // TEST CALLS
  LoadAd1(std::string(kRewardedVideoAdUnit));
  //LoadAd2(std::string(kRewardedVideoAdUnit));
  ///////////////////////////////////////////////////////////////////



  WaitForFutureCompletion(rewarded_video::LoadAdLastResult());

  // If an ad has loaded, show it. If the user watches all the way through, the
  // LoggingRewardedVideoListener will log a reward!
  if (rewarded_video::LoadAdLastResult().error() ==
      firebase::admob::kAdMobErrorNone) {
    LogMessage("Showing a rewarded video ad.");
    rewarded_video::Show(GetWindowContext());

    WaitForFutureCompletion(rewarded_video::ShowLastResult());

    // Normally Pause and Resume would be called in response to the app pausing
    // or losing focus. This is just a test.
    LogMessage("Pausing.");
    rewarded_video::Pause();

    WaitForFutureCompletion(rewarded_video::PauseLastResult());

    LogMessage("Resuming.");
    rewarded_video::Resume();

    WaitForFutureCompletion(rewarded_video::ResumeLastResult());
  }

  LogMessage("Done!");

  // Wait until the user kills the app.
  while (!ProcessEvents(1000)) {
  }

  rewarded_video::Destroy();
  firebase::admob::Terminate();
  delete app;

  return 0;
}

Andrei Lazutin

unread,
Jan 2, 2019, 4:04:00 PM1/2/19
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
Don't forget to set your own YOUR REWARDED AD UNIT ID"

mobileadssdk-a...@google.com

unread,
Jan 3, 2019, 3:06:44 PM1/3/19
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hello Andrei, 

Thank you for the additional details. I was able to troubleshoot the issue further on my end. It looks like the string is not converting the value to the char. Please check this related StackOverflow post as a reference. Since you're able to load the ads using the static variable, it looks like this is an implementation issue. We only handle technical SDK implementation queries on this forum. If you continue to have an issue with this, we suggest that you post your concern on other developer forums. 

Regards,
Bharani Cherukuri
Mobile Ads SDK Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

Andrei Lazutin

unread,
Jan 3, 2019, 3:36:30 PM1/3/19
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
Same code works fine on Android ... why? Looks like sub on SDK side. Why I can't pass c_str()?

To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
To post to this group, send email to google-adm...@googlegroups.com.

Andrei Lazutin

unread,
Jan 3, 2019, 3:39:30 PM1/3/19
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
string is converting the value to the char, I use c_str() as you can see ... 

Also why LoadAd1() crashes? but LoadAd2() don't crashes?

mobileadssdk-a...@google.com

unread,
Jan 4, 2019, 3:03:37 PM1/4/19
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hello Andrei, 

The Rewarded videos are controlled by the static methods in the rewarded_video namespace. To access the rewarded_video namespace you will need to pass all the parameters in the LoadAd() method. In the second method, you're declaring it as static which is resetting the values and creating a new namespace. Please find the attached screenshots as a reference in both the scenarios. You may also refer to this guide for more information. 

Regards,
Bharani Cherukuri
Mobile Ads SDK Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 01/03/19 15:39:06 mrpu...@gmail.com wrote:
string is converting the value to the char, I use c_str() as you can see ... 

Also why LoadAd1() crashes? but LoadAd2() don't crashes?

On Thu, Jan 3, 2019 at 11:36 PM Andrei Lazutin <mrpu...@gmail.com> wrote:
Same code works fine on Android ... why? Looks like sub on SDK side. Why I can't pass c_str()?

To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
Screen Shot 2019-01-04 at 9.43.55 AM.png
Screen Shot 2019-01-04 at 9.43.18 AM.png

mobileadssdk-a...@google.com

unread,
Jan 7, 2019, 5:28:33 PM1/7/19
to Andrei Lazutin, Google Mobile Ads SDK Developers
Hello Andrei, 
My name is Jon and I'm looking into this for you. Unfortunately for now all I can tell you is that if using a static reference works for you then that's what you should do. Thanks.  

Jon


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 01/05/19 02:37:38 mrpu...@gmail.com wrote:
But this is insane use static parameters to call static methods! I don’t see any reasons why I should use static parameters. 

Also, I don’t see any notes about such weird staticness... why android works without static params?

пт, 4 янв. 2019 г. в 23:03, <mobileadssdk-advisor+support@google.com>:
Reply all
Reply to author
Forward
0 new messages