It is possible, but Iām not going to do at the moment, as I still need to test basic functionality and fix some bugs.
Hi @pozirk,
Youāre a lifesavior, I spent most of the afternoon testing several google ads libraries for openfl and they all seemed at least 4+ years old and broken at this point. Which would make me want to avoid making Android apps using openfl.
If you donāt mind my inexperienced questions, I tried building the app but got errors in the AdMobEx dependency:
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdMobEx.java:46: error: class AdmobEx is public, should be declared in a file named AdmobEx.java
public class AdmobEx extends Extension
^
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdMobEx.java:16: error: cannot find symbol
import com.google.android.gms.ads.AdError;
^
symbol: class AdError
location: package com.google.android.gms.ads
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdMobEx.java:21: error: cannot find symbol
import com.google.android.gms.ads.FullScreenContentCallback;
^
symbol: class FullScreenContentCallback
location: package com.google.android.gms.ads
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdMobEx.java:22: error: cannot find symbol
import com.google.android.gms.ads.LoadAdError;
^
symbol: class LoadAdError
location: package com.google.android.gms.ads
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdMobEx.java:24: error: cannot find symbol
import com.google.android.gms.ads.RequestConfiguration;
^
symbol: class RequestConfiguration
location: package com.google.android.gms.ads
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdMobEx.java:25: error: package com.google.android.gms.ads.initialization does not exist
import com.google.android.gms.ads.initialization.InitializationStatus;
I have followed your advice to use Android SDK v.30 and Gradle version 6.7.1.
Any ideas how I could fix that, as I would really like to try out your library?
Thanks in advance
PS: You may need to create a new fork of the library with a new name to push it to haxelib. In particular, do mind the naming āAdMob.hxā instead of āAdmob.hxā to remain consistent.
Hey agbephh!
FIrst, you need to rename AdMobEx.java to AdmobEx.java, looks like Github kept old file name.
For āsymbols not foundā, I guess you donāt have Google Play services installed from SDK Manager.
Iām not at my computer at the moment, will be able to check for sure only in a week.
Yeah, I kind of didnāt like āAdMobā, so renamed everything to āAdmobā, but Github left it as before.
So, you should rename to āAdmob.hxā too.
Let me know, how it goes.
Hey @pozirk, thank you for your involvement!
I have tried with these installed:
and I still get these same errors, ending with:
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdmobEx.java:257: error: cannot find symbol
InterstitialAd.load(mainActivity, id, adRequest, new InterstitialAdLoadCallback() {
^
symbol: class InterstitialAdLoadCallback
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdmobEx.java:257: error: cannot find symbol
InterstitialAd.load(mainActivity, id, adRequest, new InterstitialAdLoadCallback() {
^
symbol: variable InterstitialAd
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdmobEx.java:332: error: cannot find symbol
RewardedAd.load(mainActivity, id, adRequest, new RewardedAdLoadCallback() {
^
symbol: class RewardedAdLoadCallback
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdmobEx.java:332: error: cannot find symbol
RewardedAd.load(mainActivity, id, adRequest, new RewardedAdLoadCallback() {
^
symbol: variable RewardedAd
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdmobEx.java:380: error: cannot find symbol
_rewarded.show(mainActivity, new OnUserEarnedRewardListener() {
^
symbol: class OnUserEarnedRewardListener
C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdmobEx.java:417: error: cannot find symbol
return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(mainContext, adWidth);
^
symbol: method getCurrentOrientationAnchoredAdaptiveBannerAdSize(Context,int)
location: class AdSize
Note: C:\Users\AgbePhH\Git\test\GameExport\android\bin\deps\admobex\src\admobex\AdmobEx.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
27 errors
FAILURE: Build failed with an exception.
I read this might need some specific changes in the build.gradle, but I donāt know how it translates in terms of OpenFL configurations.
Apologies as I understand it is not the fault of your implementation of Admob
Iām not sure why you have these errors, as I never had them myself, but looks like itās still canāt get to Google Play service APIs.
So letās try to recreate the same environment, that I have:
- Download android-ndk-r21e
- Run
openfl setup android
to set correct path for android sdk and ndk - Check this thread and follow the steps I took to fix problems with Lime: https://github.com/haxelime/lime/issues/1476
- Install
extension-googleplayservices-basement
and add it to your project
Try to rebuild project after each step to see what fixes the problem. I think 4th step is the solution.
Hello
Please tell me if you need me to create a new topic for the issues weāre discussing.
Iāve added the following to the project (the lib was already installed on haxelib) and it doesnāt fix the issue
<haxelib name="extension-googleplayservices-basement" />
Iām very confused about the NDK. I read it was somewhat optional when you have the SDK. I was using an older ār15cā NDK.
I tried switching to NDK-r21e following your advice, but it seems to make clang++ mandatory, which I donāt have.
Being on Windows 10, I tried the following steps:
- Installed CMake.
- Installed Ninja for the generator.
- Installed Mingw for gcc and g++.
- Tried building LLVM (for CLANG++) but encountered errors.
Do you have any source to understand why a more recent NDK is required?
Do you confirm I need to have clang++ as a compiler for it?
It seems g++ no longer builds Android.
Perhaps we need to closely follow this issue.
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.
- Framework at the left tree panel
- 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.
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.
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.