Error: SDK tried to perform a networking task before being initialized

538 views
Skip to first unread message

Liene Ungure

unread,
May 11, 2022, 1:42:22 AM5/11/22
to Google Mobile Ads SDK Developers
Hi! I was told to post my problem here.

I have created custom adapter/events framework for interstitial and rewarded video ads that uses GADMediationAdapter. Tested framework on native iOS app and it works. 

When I added framework into Unity project and build it to Xcode, got the error SDK tried to perform a networking task before being initialized when tried to load Interstitial or Rewarded video adsAll of the ads are called after 'MobileAds.Initialize' callback.

I tried adding only AdMob GoogleMobileAdsSDK to my Unity project, got test ads, everything worked. Then tried to add my framework - got the error. 

Found that adding UnityFramework.framework to Xcode Build Phases -> Link Binary With Libraries fixes my problem and I got the right ads from custom event. 

For users all of the setting should be set in Unity, not Xcode, because some are building to the cloud.

Unity version: 2020.3.33f1
AdMob Unity plugin version: 7.0.0
Xcode version: 13.3
AdMob version: 9.4.0
MacOS version: Monterey 12.0.1
iOS version: 15.4.1

Any idea what might be wrong and how to fix it inside Unity? 

Best regards

Liene Ungure

unread,
May 11, 2022, 4:42:12 AM5/11/22
to Google Mobile Ads SDK Developers
This is the full error message:

Error Domain=com.google.admob Code=2 "SDK tried to perform a networking task before being initialized." UserInfo={NSLocalizedDescription=SDK tried to perform a networking task before being initialized., gad_response_info=  ** Response Info **

    Response ID: (null)

    Network: (null)


  ** Mediation line items **

}

Found in AdMob docs, that code 2 is "The ad request was unsuccessful due to network connectivity. "

I'm pretty sure that network connectivity is not the cause of my problem. 

Mobile Ads SDK Forum Advisor

unread,
May 11, 2022, 10:18:17 AM5/11/22
to liene...@bidstack.com, google-adm...@googlegroups.com

Hi Liene,

Thank you for reaching out to us.

With regard to your concern, can you provide more details on what framework do you add that return this error? Also, the error code 2 means that there was an error loading data from the network.

Regards,

Google Logo
Princess Pamela
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2arjgR:ref

Liene Ungure

unread,
May 12, 2022, 3:09:05 AM5/12/22
to Google Mobile Ads SDK Developers

This framework is a custom adapter, created using these docs: https://developers.google.com/admob/ios/custom-events/rewarded
Framework is added to cocoapods and works in native iOS apps through pods. 

The only issue is with Unity. I have added it to Dependencies, exported project to Xcode. When I run the project, I got this error: Error Domain=com.google.admob Code=2 "SDK tried to perform a networking task before being initialized." UserInfo={NSLocalizedDescription=SDK tried to perform a networking task before being initialized.

This error disappears when I add UnityFramework.framework to Xcode Builds Phases -> Link Binary With Libraries. I don't change or restart network. 
I have no idea why this change fixes this issue.

As I mentioned in my first message, for users all of the setting should be set in Unity, not Xcode, because some are building to the cloud. 

Mobile Ads SDK Forum Advisor

unread,
May 13, 2022, 2:22:48 AM5/13/22
to liene...@bidstack.com, google-adm...@googlegroups.com

Hi Liene,

Thank you for sharing this with us.

If you're implementing the AdMob SDK on Unity, then you need to set all the configuration on Unity, before exporting or building it to the native iOS or Android to avoid any errors.

Liene Ungure

unread,
May 16, 2022, 3:14:26 AM5/16/22
to Google Mobile Ads SDK Developers
Hi! Thanks for your answer! 

I checked everything again from the Unity side as it is described in your manual, everything is fine. 

So, I have created custom event (like in this docs: https://developers.google.com/admob/unity/custom-events) and added it in Unity project through Dependencies.xml.
Also, I added AdInspector to my Unity project. When I open it, it looks like this: 
IMG_0030.PNG

As you see, there is label that "Adapter is ready" for both of my custom events. 

Also, my logs still look like this:
Adapter: BidstackInterstitialEvent is initialized. 
AdMobManager:<Start>b__10_0(InitializationStatus) 

Adapter: BidstackRewardedEvent is initialized. 
AdMobManager:<Start>b__10_0(InitializationStatus) 

 Adapter: GADMobileAds is initialized. 
AdMobManager:<Start>b__10_0(InitializationStatus) 

 MobileAds.Initialize initStatus: GoogleMobileAds.Api.InitializationStatus 
AdMobManager:<Start>b__10_0(InitializationStatus) 

 event received with message: Error Domain=com.google.admob Code=2 "SDK tried to perform a networking task before being initialized." UserInfo={NSLocalizedDescription=SDK tried to perform a networking task before being initialized., gad_response_info= ** Response Info ** Response ID: (null) Network: (null) ** Mediation line items ** }

As you see, I got that every adapter is inititalized, but then on load there is error. 

Mobile Ads SDK Forum Advisor

unread,
May 16, 2022, 11:36:07 AM5/16/22
to liene...@bidstack.com, google-adm...@googlegroups.com

Hi Liene,

Thank you for sharing this with us.

Can you provide us your sample app implementation on this so that we can further look into this behavior?

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002arjgRQAQ&entry.80707362=00106988
2. Fill out all fields, and attach your file(s).
3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages