question

jianghuafan avatar image
jianghuafan asked

Ads for Unity can not work well

AmazonMobileAds Unity Plugin(Android) can not work well. Code: mobileAds= AmazonMobileAdsImpl.Instance; ShouldEnable enable = new ShouldEnable(); enable.BooleanValue = true; mobileAds.EnableLogging(enable); mobileAds.EnableTesting(enable); mobileAds.EnableGeoLocation(enable); ApplicationKey key = new ApplicationKey(); key.StringValue = "824513df5391479da04def3655e94bdc"; mobileAds.SetApplicationKey(key); Ad response = mobileAds.CreateInterstitialAd(); LoadingStarted response = mobileAds.LoadInterstitialAd(); Error Message: KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.List`1[com.amazon.mas.cpt.ads.IDelegator]].get_Item (System.String key) [0x00000] in :0 at com.amazon.mas.cpt.ads.AmazonMobileAdsImpl.FireEvent (System.String jsonMessage) [0x00000] in :0 at com.amazon.mas.cpt.ads.AmazonMobileAdsImpl+AmazonMobileAdsBase.UnityFireEvent (System.String jsonMessage) [0x00000] in :0
mobile ads
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

justin avatar image
justin answered
Hi jianghuafan, Could you share your actual source for this method? I don't see your Start or class methods. Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jianghuafan avatar image
jianghuafan answered
Play Amazon Ads need 4 Setps: SetApplicationKey,CreateInterstitialAd,LoadInterstitialAd,ShowInterstitialAd I think these 4 setps is start method. I don't know I need other start method ? I can't find any sample on Unity Plugin. LoadInterstitialAd can not work well. I need you help, Thanks. if( GUILayout.Button( "Init",GUILayout.Width(200f), GUILayout.Height (200f))) { mobileAds= AmazonMobileAdsImpl.Instance; ShouldEnable enable = new ShouldEnable(); enable.BooleanValue = true; mobileAds.EnableLogging(enable); mobileAds.EnableTesting(enable); mobileAds.EnableGeoLocation(enable); ApplicationKey key = new ApplicationKey(); key.StringValue = "824513df5391479da04def3655e94bdc"; mobileAds.SetApplicationKey(key); } if( GUILayout.Button( "CreateInterstitialAd" ,GUILayout.Width(200f), GUILayout.Height (200f)) ) { Ad response = mobileAds.CreateInterstitialAd(); // Get return values string adType = response.AdType.ToString(); long identifier = response.Identifier; } if( GUILayout.Button( "LoadInterstitialAd" ,GUILayout.Width(200f), GUILayout.Height (200f)) ) { LoadingStarted response = mobileAds.LoadInterstitialAd(); bool loadingStarted = response.BooleanValue; Debug.Log ("loadingStarted: " + loadingStarted); } if( GUILayout.Button( "Play" ,GUILayout.Width(200f), GUILayout.Height (200f)) ) { AdShown response = mobileAds.ShowInterstitialAd(); bool adShown = response.BooleanValue; Debug.Log ("adShown: " + adShown); }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

justin avatar image
justin answered
Hi jianghuafan, Your buttons ([code]if(GUILayout.Button)[/code]) will need to be set up in OnGUI () {} methods, as Start only runs once. Thanks,
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

justin avatar image
justin answered
Hi Jiang, Could you please try the following steps at the bottom of this thread, and let us know your results? https://forums.developer.amazon.com/forums/thread.jspa?threadID=5939&tstart=0 Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.