Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tutorial: Add admob interstitial ads to your CoronaCards Windows Phone 8 app
Started by spacewolf Nov 01 2014 05:43 PM

33 replies to this topic
coronacards windows phone 8 wp8 tutorial admob advertising interstitial ads google
[TOPIC CONTROLS]
Page 1 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

For anyone interested I created this tutorial on how to integrate admob interstitial ads into your corona windows phone 8 app:

 

http://www.spacewolfsoftware.com/blog/tutorial-add-admob-interstitial-ads-to-your-corona-windows-phone-8-app/

 

Hope this helps!



[TOPIC: post.html]
#2

r.delia

[GLOBAL: userInfoPane.html]
r.delia
  • Contributor

  • 139 posts
  • Corona SDK

Thanks spacewolf, That's awesome!  Hopefully I'll get to go through it soon!



[TOPIC: post.html]
#3

bubblebobble

[GLOBAL: userInfoPane.html]
bubblebobble
  • Contributor

  • 309 posts
  • Corona SDK

Hi Spacewolf,

appreciate the time taken for you to put this togethor.

I had solved the banner ads and was going to sort the fullscreen out BUT you saved me lots of time.

Will test it out later today

good job



[TOPIC: post.html]
#4

bubblebobble

[GLOBAL: userInfoPane.html]
bubblebobble
  • Contributor

  • 309 posts
  • Corona SDK

Ok, Iam having issues trying to get to interstitials working, maybe it is my lack of experience .

So I built a complete fresh project and tried to build the example....hmmm  no joy.

Can someone verify its working correctly please



[TOPIC: post.html]
#5

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

What error are you getting?

 

I added some details about how to successfully compile the sample application when you download it.



[TOPIC: post.html]
#6

bubblebobble

[GLOBAL: userInfoPane.html]
bubblebobble
  • Contributor

  • 309 posts
  • Corona SDK

@spacewolf,

hi, no problems now all fixed.

I was adding the code to an original project, now I did it the opposite way round and all is good.

Thanks for formatting the code also, excellent job, thumbs up !



[TOPIC: post.html]
#7

prodesuka

[GLOBAL: userInfoPane.html]
prodesuka
  • Observer

  • 13 posts
  • Corona SDK

Thanks for your tutorial Spacewolf. I can run the sample project without any issues.

When I try to apply your tutorial steps to my own project however, I get the following errors in Visual Studio Express 2013 for Windows Update 3:

 

The type or namespace name 'InterstitialAdControl' could not be found (are you missing a using directive or an assembly reference?) 

 

The name "LocalizedStrings" does not exist in the namespace
 

 

Any idea what the underlying cause could be? The project runs fine (although without ads) when not applying the steps described in the tutorial.

One difference between the sample project and mine I've noticed is that my .sln and .suo files are in a directory higher than de files of the rest of my project. However, simply moving the .sln and .suo files to the same dir as  the rest of the files causes the project to be unusable.
 



[TOPIC: post.html]
#8

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

@prodesuka

 

The first error means the compiler can't find the class definition for your InterstitialAdControl class. 

  • Open InterstitialAdControl.cs - after the using statements at the top of the file you should see a line something like "namespace xxxxxxxxxxxxxxx". This line declares the namespace of the class. The namespace should match the rest of your project namespace. For example, if your project were named "ShooterGame", than this line should look like "namespace ShooterGame". You can open up MainPage.xaml.cs and look at the namespace line there. The namespace line in InterstitialAdControl.cs should match that.

I've updated the tutorial to fix this problem. Thanks for bringing it up!

 

It actually doesn't matter where the solution files are located. When you created the project, you can choose to have the solution files in their own directory or in with the project files (specified by checking a box next to this option or not in the create project dialog.)



[TOPIC: post.html]
#9

prodesuka

[GLOBAL: userInfoPane.html]
prodesuka
  • Observer

  • 13 posts
  • Corona SDK

The namespace change worked, thanks.



[TOPIC: post.html]
#10

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

I get the error message below when I try and add the AdMob reference to the project...any ideas what the problem is?

 

ERROR: A reference to a higher version or incompatible assemly cannot be added to the project.



[TOPIC: post.html]
#11

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

I found the solution:

 

The file is being blocked by Windows, as downloaded content is deemed unsafe. The solution is to right-click on the unpacked monitor file, select Properties, and click Unblock.



[TOPIC: post.html]
#12

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

@Mike 

 

Thanks for posting the solution! I'll see if I can add this gotcha to my tutorial.



[TOPIC: post.html]
#13

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

Anybody know how to solve this error message?

 

Error 1 Retrieving the COM class factory for component with CLSID {2D0A16C9-53D9-42C1-BCC2-8D2A135E2163} failed due to the following error: 8001010e The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)). 0 0


[TOPIC: post.html]
#14

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

This probably means your code is trying to update a UI component when your code is not running on the UI thread. Are you building for 8.0 or 8.1?

 

If you are building for 8.0, try wrapping that particular code in this:

Dispatcher.BeginInvoke(() =>
{
    // Place the code that accesses your UI component in here.
});

This will marshall your code onto the U.I. thread.



[TOPIC: post.html]
#15

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

@spacewolf 

 

The target OS is 8.0 like you specify in your tutorial. Where do I put the code you have listed above?



[TOPIC: post.html]
#16

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

Did you download, compile, and run the sample application? If so it should run as-is.

 

If you are you are trying to integrate the admob code into a different project then I would need to see your code. Can you track down the line of code and method that is throwing the exception your getting?



[TOPIC: post.html]
#17

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

First I tried it in my own project and when I got the error I did it on your download example and get the same error. How do I  track down the line of code and method that is throwing the exception?

 

FYI ... I am using Visual Studio Express 2013 and Corona Cards 2506



[TOPIC: post.html]
#18

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

You could try setting breakpoints at various places in the C# code and then stepping through with the debugger and see exactly when the exception gets thrown.



[TOPIC: post.html]
#19

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

I updated to the newest version of Corona Cards and now I get the following error...any ideas what is going on?

 

Error 1 Exception from HRESULT: 0x89721800 0 0
 
Now this is happening to all of my projects which were fine before!


[TOPIC: post.html]
#20

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

How can determine if an ad has been show on the LUA side of things?



[TOPIC: post.html]
#21

spacewolf

[GLOBAL: userInfoPane.html]
spacewolf
  • Contributor

  • 298 posts
  • Enterprise

@Mike

 

I'm not sure what that exception means but your best bet in tracking down the problem would be to do like I said before and set breakpoints throughout various parts of your code and step through using the debugger to see if you can catch the problem code.

 

For your second question, do you mean you want admob to notify you in lua when an ad as been shown or you want to call a lua method and check to see if an ad has been shown?

 

The former you would need to setup a LUA listener as described in this guide: http://docs.coronalabs.com/daily/coronacards/wp8/communication.html

 

The latter you can just add another C# listener like the other ones you setup in the tutorial and have it return true if admob showed an ad or false if not.



[TOPIC: post.html]
#22

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

I was talking about the second way.



[TOPIC: post.html]
#23

Mike Hempfling

[GLOBAL: userInfoPane.html]
Mike Hempfling
  • Contributor

  • 251 posts
  • Corona SDK

@spacewolf

 

It would be awesome if you could include the code examples for determining if an ad had shown in your tutorial. I have never programmed in C# so I would be very thankful if you could add it to the tutorial.



[TOPIC: post.html]
#24

samirj

[GLOBAL: userInfoPane.html]
samirj
  • Observer

  • 22 posts
  • Corona SDK

 @SpaceWolf – thanks a lot for this code. It works beautifully. I sincerely appreciate your help. Thanks again.



[TOPIC: post.html]
#25

bgmadclown

[GLOBAL: userInfoPane.html]
bgmadclown
  • Contributor

  • 703 posts
  • Corona SDK

Is it possible to port this tutorial to banner ads? I could really use a step by step tutorial like that.




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]