I am implementing admob in my iOS module using this guide.
I have a view controller where my interstitial ads are initialized like this
@CustomClass
public class ViewController extends UIViewController implements ActionResolver {
private GADInterstitial interstitial;
private static final String AD_UNIT_ID = "ca-app-pub-XXXXXXXXXXXXXXXX-XXXXXXXXXX";
public ViewController() {
viewDidLoad();
}
@Override
public void viewDidLoad() {
super.viewDidLoad();
interstitial = createAndLoadInterstitial();
}
private GADInterstitial createAndLoadInterstitial() {
//Ad Unit ID of your interstital, from adMob account.
GADInterstitial interstitial = new GADInterstitial(AD_UNIT_ID);
System.out.println("Add unit ID is " + AD_UNIT_ID);
interstitial.setDelegate(new GADInterstitialDelegateAdapter() {
@Override
public void didDismissScreen(GADInterstitial ad) {
ViewController.this.interstitial = createAndLoadInterstitial();
}
});
interstitial.loadRequest(createRequest());
return interstitial;
}
private GADRequest createRequest() {
GADRequest request = new GADRequest();
// To test on your devices, add their UDIDs here:
request.setTestDevices(Arrays.asList(GADRequest.getSimulatorID()));
return request;
}
@IBAction
public void showInterstitialAd() {
if (interstitial.isReady()) {
interstitial.present(UIApplication.getSharedApplication().getKeyWindow().getRootViewController());
System.out.println("Interstitial is loaded.");
} else {
interstitial.loadRequest(createRequest());
System.out.println("Interstitial not ready!");
}
}
}
My implementation is similar to this guide also.
When I run my app on the simulator I get the following exception.
org.robovm.objc.ObjCClassNotFoundException: GADInterstitial
at org.robovm.objc.ObjCClass.getByType(ObjCClass.java:251)
at org.robovm.objc.ObjCClass.getFromObject(ObjCClass.java:212)
at org.robovm.objc.ObjCObject.getObjCClass(ObjCObject.java:161)
at org.robovm.apple.foundation.NSObject.alloc(NSObject.java:214)
at org.robovm.objc.ObjCObject.<init>(ObjCObject.java:79)
at org.robovm.apple.foundation.NSObject.<init>(NSObject.java:157)
at org.robovm.pods.google.mobileads.GADInterstitial.<init>(GADInterstitial.java:52)
at com.nauv.fut.simulator.ViewController.createAndLoadInterstitial(ViewController.java:39)
at com.nauv.fut.simulator.ViewController.viewDidLoad(ViewController.java:34)
at com.nauv.fut.simulator.ViewController.<init>(ViewController.java:27)
at com.nauv.fut.simulator.IOSLauncher.createApplication(IOSLauncher.java:30)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication$Delegate.didFinishLaunching(IOSApplication.java:65)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication$Delegate.$cb$application$didFinishLaunchingWithOptions$(IOSApplication.java)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:413)
at com.nauv.fut.simulator.IOSLauncher.main(IOSLauncher.java:35)
I have imported the admob framework on my ios build.gradle. I have also tried moving it to ios module in main build.gradle though this doesnt change anything. How can I fix this error? My class is being imported correctly and I am using project.ext.robopodsVersion = "1.14.0"
on my app build.gradle.