Extension-admob

I’m on windows 8, there is no need to install all this, android-ndk-r21e is working fine.
Make sure to install the latest version of haxe 4.2.4, openfl, hxcpp, lime

android-ndk-r23b is not going to work with Lime!
Java can be any, I think, but I have jdk1.8.0_301.

Hi @pozirk, I’ve been trying to get your AdMob extension working but seem to be hitting problems for both Android and iOS. Any help would be appreciated. I’m on OSX 10.15 (Catalina) and using XCode 12 (tried 11.3 but got issues with the tracking transparency with iOS 14 so moved to 12).

For iOS, the build seems to go most of the way through but then fails with:

Framework not found GoogleMobileAds

Even though the GoogleMobileAds.framework is listed in the project Frameworks folder - I’m not sure how to fix this.

For Android, as I mentioned above, using XCode 11.x didn’t build due to the tracking transparency with iOS 14. With XCode 12, the build again goes to the final gradle steps then fails with references to:

Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > The minCompileSdk (31) specified in a
     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
     is greater than this module's compileSdkVersion (android-30).
     Dependency: androidx.work:work-runtime:2.7.0.

I’m targetting Android-30 and there are several solutions on Google about forcing/adding a dependency or api reference to the work-runtime:2.6.0 - to get around the error, but none that I’ve tried seem to work, or I’m just not putting the fixes in the correct build.gradle location. I’ve also tried using Android-31 which supports the 2.7.0 version and first time it complained that Android 12 needed an ‘android:exported=“false/true”’ parameter - I added this (true and false) and the build succeeded but getting a blank screen.

Things just seem to have moved on versions since your helpful post and it’s just got a bit complicated for me.

Thanks

Greg

I’m on MacOS 12 and XCode 13, not sure if it makes any difference.
There are 2 ways to add a framework and one of them not working as expected.

  1. Framework at the left tree panel
  2. General project properties - this one, as I recall, didn’t work, didn’t actually add a framework

You are not supposed to add GoogleMobileAds.framework manually, it should be added by extension, but try to remove it and re-add, make sure it’s from extension, see Path at the top right corner.





For Android, I think I had this issue myself, fix similar to this one helped:


I’m not sure why I didn’t metion it in readme, I guess, I was hoping the problem would go away eventually, cause it’s just SDK version mismatch.
You need to add it to Lime bulid.gradle though:
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
	buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
	
	lintOptions { //pozirk - this might help with other problems
		checkReleaseBuilds false
	}
	
	defaultConfig {
		applicationId "::META_PACKAGE_NAME::"
		minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
		targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
		versionCode Integer.parseInt(project.VERSION_CODE)
		versionName project.VERSION_NAME
		::if (languages != null)::resConfigs ::foreach languages::"::__current__::", ::end::""::end::
		
		configurations.all { //pozirk - should fix your problem
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
		}
	}

It might actually worked for you with SDK31, listen for extension events to see if you initialize it correctly and check adb logs, admob doesn’t show any ads except test in debug version, so blank screen is normal.

Thanks for the reply. I’m making progress - I think. Android is building using your build.gradle changes and SDK 30 but I’m getting a blank screen still. I’m only using banner ads and the test ad appears but my app content doesn’t. If I remove the extension-admob my app displays fine. So still working on that on.

I’m still having iOs build issues so may need to try xcode 13.

Will keep trying. Thanks again.

Greg

Hi @pozirk. Unfortunately I haven’t been able to get any further with these issues for both Android and iOS, and I’m runnning out of ideas. I’m using the current released versions of OpenFL(9.1.0) and Lime(7.9.0). Other versions are: Haxe=4.2.4, hxcpp=4.2.1, hxp=1.2.2, your extension-admob=2.0.1 (using the ./buildPackage.sh and .installPackage.sh and that created the zip).

Android: SDK: 30 m& NDK: 21e

  • Doing a ‘lime rebuild android -clean’ does nothing as I’m on the released version of OpenFL/Lime.
  • If I use the latest git versions of both I’m unable to build lime as I get load of errors which I think is due to NDK21 as opposed to the suggested version NDK 15c
  • I’ve added the following to the template AndroidManifest.xml node:
    tools:remove=“android:appComponentFactory” android:appComponentFactory=“whateverString” android:allowNativeHeapPointerTagging=“false”
  • These were from Googling about SDK 30 blank screen issues and appComponentFactory errors I saw in logcat.
  • I’ve also your recommendations in the lime gradle.properies of:
    android.useAndroidX=true
    android.enableJetifier=true

But I still get a blank screen with the exception of the test advert being shown (which is shows your part works). The application is still running and I can log screen touches and things work normally but with a blank display. There is a lot of stuff in the logcat but I can’t determine if there is anything specific that is reporting anything about the blank screen. If I remove your extension but keep the SDk 30 the same happens so the extension appears to be fine.

iOS: macOS 12.3.1, XCode 13.3, iOS SDK 15.4.
No matter what I seem to try, the build gets all the way through and fails with the final linking of the GoogleMobileAds framework. I’ve added the path into the search paths, removed and re-added the framwork, moved the folder to be within the project folder, changed the order of the framework search paths and probably other things as well.

The output of the clang++ command that throws the error shows that the framwork is listed and the search path is present. Running this command on it’s own fails in the same way. I’ve even tried tweaking this command manually but still no joy.

I’ve seen references to using a xcworkspace instead of the xcodeproj that OpenFL generates - but that didn’t work and I think that’s to do with using CocoaPods to add dependencies to a project. I’ve not used it before. Do you use CocoaPods at all?

Again, any help would be much appreciated.

Greg

Black screen on Android might be this:

I have the same OpenFL and Android environment as you.

I’m not sure why for iOS it can’t find GoogleMobileAds framework. Maybe something with the naming.
Try download all the frameworks again and replace them:

I managed to get Android working. Seems my AndroidManifest.xml template wasn’t merging correctly as part of the build. I’m now using SDK 31 and the test ad is working.

For iOS, which version of the Mobile Ads SDK are you using in the extension. When I use the latest 9.3.0 I get compilation errors as there are differences in the API. I’ve tried to change the AdmobEx.mm to correct the differences but I’m battling with an error in the way things are now implemented with GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth - Can’t quite figure out how to fix it yet.

Did you use work-runtime:2.7.0 with Android SDK31?

For iOS, I’m using Mobile Ads SDK 8.11, they’ve made some changes again in v9, so annoying.

Yes (I think so). I removed the resolutionStrategy and the lintOptions and have built both debug and release versions. The debug showed the test ads but the release version showed nothing but I suspect that is due to the app not being available on the store and the AdMob banner still under ‘review’.

I’ve not retried 8.11 yet but have been looking at 9.3 still for iOS. I have managed to get a clean build that ran but didn’t show the test ad. To get it to build, I removed the

self._banner = [[GADBannerView alloc] initWithAdSize:GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)];

with

self._banner = [[GADBannerView alloc] initWithAdSize:GADAdSizeBanner];

Still can’t figure out why it complains about GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth.

I also had to tweak the buildPackages and installPackages. Firstly, with the buildPackages, when building for iOS, I had a runtime failure immediately as it complained that no AdMob ID had been provided in the Info.plist. This was due to the zip file not containing the templates folder. Secondly, with the installPackages I’ve changed it to use haxelib install extension-admob.zip as haxelib local gave a warning about being deprecated.

Well, I will update extension to th latest iOS SDK eventually, but I’m not sure on timing.

Shouldn’t be problems with Admob ID, have you provided it in your project.xml?
File extension-admob-Info.plist from templates folder should be inserted in your Info.plist automatically.

No problem. I appreciate your efforts on this so far and the help you’ve given. It doesn’t help how rapidly these changes come and force updates to different things and then break others. It’s hard keeping everything up-to-date.

The AdMob ID issue was probably due to me using the buildPackages.sh and installPackages.sh method which didn’t include the templates folder in the zip - so the haxelib version didn’t contain that folder. Not a problem as I got that fixed.

I’m probably going admob free for a little while until I’ve got it all working so I can at least get some kind of release out (and verified that I can get through the process end-to-end).

I’ll probably come back to it in a week or so.

I think I will be able to update extension with the latest changes somewhere in May as I need to update my own games at AppStore.

1 Like

Thanks for all your best works. It seems the extension will work well for both Android and iOS.
And just my opinion, someone could improve the iAp extension. For my last try, it did not work at all with newest Android library. Donation can be made from other devs.:grin:

I’ve tested extension on Android with the latest Google Play Services 49 (ie Mobile Ad SDK 20.6.0) and Android SDK 31.
Both debug and release versions show ads fine for me, I’ve tried interstitial only.
Android now requires to have new permission <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>, I will update github version soon.

I see some warnings about depreciated methods in the extension, but not sure how to check what these methods are.
Does anyone know?

I will check iOS version of the extension next.

1 Like

Extension works fine for iOS as well with the latest Mobile Ads SDK 9.4.0, just required some minor updates.
The only problem, I had the same error with initWithAdSize:GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth as @Greg209, looks like it’s SDK bug. So, I have commented it out for now, ie. Adaptive Banner is not going to work, other sizes should be fine, let’s hope they will fix it soon.

I will update github version next week.

1 Like

Hi @pozirk.

Just tried the latest from GitHub and apart from a couple of things I’ve now managed to get the test adverts working on both Android and iOS. Thanks for the update. One thing I did differently was to setup the repo using haxelib dev <path to folder> and building manually rather than using the buildPackages.sh and installPackages.sh.

The couple of things are :

  1. In the repo, the folder ‘frameworks’ has a typo in it - ‘framworks’ without the ‘e’.
  2. I wanted to test on an iOS device and had to modify the AdmobEx.mm Ln #387 to specify an explicit device ID for testing, as it didn’t work trying to establish the ID in code. The ID I used came from the console output when I tried the build originally.

Thanks again.

Yep, I’ve fixed framworks.
buildPackages.sh and installPackages.sh are from original haxe extension, I’ve never used them myself. :slight_smile:
Was something confusing about test ads for iOS, but regular ads worked fine for me, so I didn’t test that.
It’s different for Android, for debug build, you need test ads for them to work.

Big update v2.2.0
I’ve added GDPR support for EEA and UK as it will be soon required by Admob.
New version is available on Github only, I would like to test it a bit more before pushing to haxelib.

Anyone from EEA or UK willing to test? :slight_smile:

3 Likes

Hi Pozirk,
Thank you for your hard work on upgrading the extension-admob.
I have a couple of questions about the new extention.

1.) The old extension had a function called tagForChildDirectedTreatment().
It was used to tell admob to show only child friendly ads. Is there something similar in the upgrade?

2.) Should I use Admob.loadInterstitial(INTERSTITIAL_ID); every time I want to show an interstitial. Or should I just load it once when the game starts and then just use Admob.showInterstitial() each time I want to show an ad.

3.) The old showInterstitial() had some params to limit how often that ad is shown.
- To avoid displaying the interstitial if the game was too short (60 seconds), call: AdMob.showInterstitial(60);
Does the upgrade have the same?

I did not upgrade the games for 4+ years. So I am sorry if some of the questions are too ignorant of current admob requirements.

Hey,

  1. Yes, second parameter for init() function is childDirected, set it to true to enable only children friendly ads. I have never tested it though.

  2. You need to call loadInterstitial each time you want to load a new ad.
    Admob has frequency cap in the settings of your ad unit, where you can setup how often you want it to be shown. Or you can have your own timer. I didn’t implement this functionality in the extension.

1 Like