- Home /
Unity 3 crash when I link with AdMob or AdSense
Hi,
Have anybody successfully integrated Google AdSense or AdMob with Unity3D 3 game?
My game worked flawlessly with Unity 2, but when I ported it to Unity 3 my game started to crash at startup unless I remove all ads except iAd. The problem is really weird - game crashes at random places when I link(!!!) with AdMob or AdSense libraries. The minimal configuration to trigger this crash is to link with AdMob or AdSense, put a reference to a constant or a class from these libraries somewhere in Objective C code (inside a bundle code or inside AppController) and have a script inside a scene with a reference to GUI.color. This is a pseudo code to demonstrate this situation.
AppController.m
#import "GADAdViewController.h"
...
-(void)applicationDidFinishLaunching:(UIApplication)app { //it does not matter where below line is located. It can be placed in main.mm or anywhere else as well.
....
adViewController_ = [[GADAdViewController alloc] initWithDelegate:self];
....
}
Inside Unity script
public class Test {
public void Awake() {
GUI.color = Color.red; //this code does not have to run. Having reference to GUI.color is enough.
}
}
This code does not even have to run! Having references to symbols from these static libs and a call to GUI.color is enough to make unity crash on startup at random places. My best guess is that this have something to do with static initialization or loading of Unity classes.
What I already did
- Tried to compile with GCC and LLVM without any optimizations - same results.
- Verified that removing either reference to GADAdViewController or GUI.color fixing the issue.
- Created a game from scratch, added these two lines and verified that the problem persists.
Please help, I'm running our of options to try and cannot understand what is going on.
Is there any resolution to this? I'm having a hard time finding anything anywhere showing how to impliment google ads, admob, and adsense into your unity app.
http://forum.unity3d.com/threads/77568-Ad$$anonymous$$ob-plugin-that-works-in-Unity-3.2
But unfortunatly you get a Force Close due to a class not found.