Giter VIP home page Giter VIP logo

extension-admob's Introduction

extension-admob

Google AdMob OpenFL extension for iOS and Android.
This extension allows you to integrate Google AdMob with your OpenFL application.

Features

  • iOS Mobile Ads SDK 11.5.0 (Xcode 15.1+, iOS 12+)
  • Android Mobile Ads SDK is always the latest automatically (update with SDK Manager)
  • GDPR for EEA and UK, read how to setup here: https://support.google.com/admob/answer/10113207
  • App Tracking Transparency (if iOS14+, app automatically presents user authorization request on first start)
  • COPPA, CCPA
  • Banners, Interstitial, Rewarded ads
  • Ads sound volume control
  • Events
  • Some bugs :)

Installation

To install this library, you can simply get the library from haxelib like this:

haxelib install extension-admob

Once this is done, you just need to add this to your project.xml

<haxelib name="extension-admob" />

Setup

Set the following in your project.xml, replace value with your app id from Admob:

<setenv name="ADMOB_APPID" value="ca-app-pub-XXXXX123457" if="android"/>
<setenv name="ADMOB_APPID" value="ca-app-pub-XXXXX123458" if="ios"/>

For Android:
You need to install the latest version of Android SDK Platfrom (31+), Android SDK Platfrom-Tools, Android SDK Build-Tools and Google Play services.
Version of Lime (8.2.0) doesn't support (probably?) latest Gradle version.
More details here: openfl/lime#1476

You need to set Gradle version in your project.xml file:

<config:android gradle-version="6.7.1" if="android" />
<config:android gradle-plugin="4.2.0" if="android" />

And fix some other problems with Lime, open file "\lib\lime\X,X,X\templates\android\template\gradle.properties" and add the following lines in the end of the file:

android.useAndroidX=true
android.enableJetifier=true

Also, you may need to set android sdk version to 31 or higher (as some versions of google play services requires that):

<android target-sdk-version="34" if="android" />

Sample code

import extension.admob.AdMob;
import extension.admob.AdmobEvent;

...

Admob.status.addEventListener(AdmobEvent.INIT_OK, onInitOk); //you can add more event listeners, if needed
Admob.init(); //set first param to true to enable testing ads, default is false

...

private function onInitOk(ae:AdmobEvent):Void
{
	trace(ae.type, ae.data);
	Admob.setVolume(0.5); //set sound volume to 0.5 for interstitial and rewarded ads
	Admob.setVolume(-1); //mute
	//you can start showing/loading ads after successful initialization
}

...

Admob.showBanner("[BANNER_ID]", Admob.BANNER_SIZE_BANNER, Admob.BANNER_ALIGN_TOP);

...

Admob.hideBanner();

...

Admob.status.addEventListener(AdmobEvent.INTERSTITIAL_LOADED, onLoadInterstitial);
Admob.loadInterstitial([INTERSTITIAL_ID]);

...


private function onLoadInterstitial(ae:AdmobEvent):Void
{
	Admob.showInterstitial();
}

Beginning 16 January 2024, Google will require all publishers serving ads to EEA and UK users to use a Google-certified consent management platform (CMP). This extension uses Google's UMP SDK and shows a consent dialog on the first app start. If the user does not consent, there is a high probability that ads will not work.

After the user makes the choice, the dialog is not shown anymore unless consent has expired. You can check if the GDPR dialog is required and show it manually.

How to know, if GDPR dialog is required (ie user is from UK or EEA):

if( Admob.isPrivacyOptionsRequired() == 1)
	//required

How to know, if user consented to personalized ads:

if(Admob.getConsent() == Admob.CONSENT_FULL)
	//constented, ads should work fine

You can also check consent to each purpose individually:

if(Admob.hasConsentForPuprpose(0) == 1)
	//consented to purpose 1, you should check all the purposes, there are like 10 of them (0-9)

More details about purposes and how users' consent influences ads: https://support.google.com/admob/answer/9760862#consent-policies From my experience, unless the user consents to everything ("Consent" at the initial dialog or "Accept all" at the Manage options dialog), ads will not work!

How to show privacy dialog to user again:

Admob.showPrivacyOptionsForm();

Not working, eh?

While I was working on this extension I came across lots of problems/bugs, so those links might help you, please go through them before contacting me:

  1. https://community.openfl.org/t/extension-admob/13242/12
  2. openfl/lime#1476

Games with Admob extension

Google Play: https://play.google.com/store/apps/details?id=air.com.pozirk.allinonesolitaire
App Store: https://itunes.apple.com/app/all-in-one-solitaire-free/id660577037
Win/lose/restart any game to see interstitial ad.

Disclaimer

Google is a registered trademark of Google Inc. http://unibrander.com/united-states/140279US/google.html

AdMob is a registrered trademark of Google Inc. http://unibrander.com/united-states/479956US/admob.html

License

The MIT License (MIT) - LICENSE.md

Copyright (c) 2024 OpenFL contributors

extension-admob's People

Contributors

01010111 avatar fbricker avatar gama11 avatar jgranick avatar justnajm avatar moss255 avatar pozirk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

extension-admob's Issues

Mediation-branch Instructions

Hi, can you add the instructions (in the Readme file)
for the mediation branch to
properly setup and call rewarded videos?

Thanks!

Build not finished

Hello, I have an interesting issue.
When I'm trying to compile with that extension, my build cannot be finished. Here is log of my build:

extension-android-support-v4: [** JUST IN CASE NOTICE **] Please remember to download and upgrade 'Android Support V4' on a regular basis. Read more at https://github.com/sempaigames/extension-android-support-v4

extension-googleplayservices-lib: [** JUST IN CASE NOTICE **] Please remember to download and upgrade 'Google Play Services Library' on a regular basis. Read more at https://github.com/sempaigames/extension-googleplayservices-lib
Buildfile: C:\Users\maxim\Desktop\DanceCat\export\android\bin\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 25.1.7
 [checkenv] Installed at C:\Users\maxim\AppData\Local\Android\android-sdk

-setup:
     [echo] Project Name: DanceCat
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 24.0.0 rc4
     [echo] Resolving Build Target for DanceCat...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\maxim\Desktop\DanceCat\export\android\bin\bin\rsObj
    [mkdir] Created dir: C:\Users\maxim\Desktop\DanceCat\export\android\bin\bin\rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for DanceCat...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:

And without this extension everything is good and build can be finished. So what can cause this weird issue?

dlopen failed in Android 6, using target-sdk-version="23"

Hi fbricker ,.

FIrst of all thanks for share your code/extensions im currently using two of them ( extension-share and extension-Admod) on my puzzle game "hulapuzzle", (check the credits) they works marvelous in Android 2.3 ,Android 4 and 5.

on Android 6 , i'm heaving trouble fixing this error java.lang.unsatisfiedLinkError dlopen failed Library "long_path_to/libc.so", apparently in some part of the apk generation the compiler dont copy the libc.so and also dont create a correct relative path to this library.

The funny thing about this is,.. i figured out how fix this , and i can do the fix downgrading the target-sdk-version from 23 to 22, but google dont let me publish the apk with this change, because i had already publish the apk targeting the version 23 of the sdk.

Can you please help me with this, in internet appear something about migrating from openssl to boringssl but i cant follow/understand this migration, on your code i cant find any reference to openssl ,. in google i cant find anything related with this error or is ambiguous , and i dont have any idea about how to fix this. i think you know how to do this, cause your game daktylos works fine without any trouble on android 4 and 6 , . .

Thanks in advance

Crash on android 9

I don't have an android 9 phone to test but this is an issue that I see from the google play console that it is repeatedly happening to the users of that OS.

The problem is the following:

java.lang.NoClassDefFoundError:
at jp.b (com.google.android.gms.dynamite_adsdynamite@[email protected] (100408-223214910):3)
at jo.a (com.google.android.gms.dynamite_adsdynamite@[email protected] (100408-223214910):3)
at jq.a (com.google.android.gms.dynamite_adsdynamite@[email protected] (100408-223214910):19)
at com.google.android.gms.ads.internal.util.aq.a (com.google.android.gms.dynamite_adsdynamite@[email protected] (100408-223214910):15)
at iu.a (com.google.android.gms.dynamite_adsdynamite@[email protected] (100408-223214910):19)
at iu.run (com.google.android.gms.dynamite_adsdynamite@[email protected] (100408-223214910):8)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
at ad.loadClass (com.google.android.gms.dynamite_dynamiteloader@[email protected] (100408-223214910):4)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)

I read on the admob comunity that this is fixed for newer admobs because it is something from the google play services. But the services that openfl is using are old because they are from androidSDK\extras\google\m2repository\com\google\android\gms and there it goes only to version 11.0.4.

I need to update it to version 17.1.13 https://mvnrepository.com/artifact/com.google.android.gms/play-services-ads-lite/17.1.3

I'm not sure how to do it yet.

Can't compile with the library

Hi,

i'm unable to compile the project when i include the library, i'm getting:

haxelib run openfl build C:\lala\game-hitandhide\hitandhide\application.xml android
openfl-gps-lib: [** JUST IN CASE NOTICE **] Please remember to download and upgrade 'Google Play Services Library' on a regular basis. Read more at https://github.com/fbricker/openfl-gps-lib
Called from ? line 1
Called from CommandLineTools.hx line 995
Called from CommandLineTools.hx line 23
Called from CommandLineTools.hx line 108
Called from CommandLineTools.hx line 205
Called from platforms/AndroidPlatform.hx line 286
Called from /usr/lib/haxe/std/neko/_std/sys/FileSystem.hx line 63
Called from /usr/lib/haxe/std/neko/_std/sys/FileSystem.hx line 54
Uncaught exception - std@sys_file_type
Build halted with errors (haxelib.exe).
Done(1)

i checked and i have the google play server library installed from the SDK, plus this is my setup:

C:\Users\shadowv>haxelib lis
haxe-gif: [0.3.3]
haxelib_client: [3.1.0-rc.4]
hxcpp: 3.1.37 [3.1.39]
iap: [1.0.4]
lime-tools: 1.4.0 1.5.6 [1.5.7]
lime: 0.9.7 1.0.0 [1.0.1]
nme-dev:
nme:
openfl-admob: [1.2.1]
openfl-bitfive: [2.0.0]
openfl-gpg: [1.0.0]
openfl-gps-lib: [1.0.1]
openfl-html5: [1.4.2-beta]
openfl-native: [1.4.0]
openfl-samples: [1.3.0]
openfl-share: [1.1.0]
openfl-webview: [1.0.0]
openfl: 1.4.0 2.0.0 [2.0.1]

any idea what could be the problem?

Doesn't Compile With Extension

Hi,

After adding to Project.xml, I get the following when trying to compile for Android target:

Running Pre-Build Command Line...
cmd: "C:\HaxeToolkit\haxe/haxelib" run lime build "Project.xml" android -release -Dfdb

extension-android-support-v4: [** JUST IN CASE NOTICE **] Please remember to download and upgrade 'Android Support V4' on a regular basis. Read more at https://github.com/sempaigames/extension-android-support-v4

extension-googleplayservices-lib: [** JUST IN CASE NOTICE **] Please remember to download and upgrade 'Google Play Services Library' on a regular basis. Read more at https://github.com/sempaigames/extension-googleplayservices-lib
Called from ? line 1
Called from CommandLineTools.hx line 1282
Called from CommandLineTools.hx line 25
Called from CommandLineTools.hx line 126
Called from CommandLineTools.hx line 560
Called from project/PlatformTarget.hx line 60
Called from platforms/AndroidPlatform.hx line 296
Called from /usr/lib/haxe/std/neko/_std/sys/FileSystem.hx line 63
Called from /usr/lib/haxe/std/neko/_std/sys/FileSystem.hx line 54
Uncaught exception - std@sys_file_type
Build halted with errors.

I saw that this was an issue here:
#1

But I already have lime 2. Here is my setup:

actuate: [1.7.5] admob: git [dev:C:\HaxeToolkit\haxe\lib/admob/git] extension-admob: [1.4.7] extension-android-support-v4: [1.0.0] extension-googleplayservices-lib: [1.1.0] flixel-addons: [1.1.0] flixel-demos: [1.1.1] flixel-templates: [1.0.2] flixel-tools: [1.0.2] flixel-ui: [1.0.2] flixel: 3.3.5 [3.3.6] haxelib_client: [3.1.0-rc.4] hxcpp: [3.1.39] HypGPlay: git [dev:C:\HaxeToolkit\haxe\lib/HypGPlay/git] inthebox-macros: git [dev:C:\HaxeToolkit\haxe\lib/inthebox-macros/git] lime: 2.0.0-alpha.6 [2.0.0-alpha.7] 2.0.4 openfl-samples: [2.1.0] openfl: 2.1.4 [2.1.5] 2.2.1 swf: 1.6.5 1.6.6 [1.8.6]

And I've both Google Play services and Android Support Library installed.

Any idea what the problem could be? Thanks!

After resolving gradle using marven, I am stucked here, please help.

First I was getting this error: http://community.openfl.org/t/google-play-services-lib/8078/2

I used "player_03" solution and compilation went properly but after 7/7 task it stucks here all the time :(

  • What went wrong:
    Execution failed for task ':deps:admobex:processReleaseResources'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.E
xecException: Process 'command 'D:\Android\android-sdk\build-tools\19.1.0\aapt.e
xe'' finished with non-zero exit value 1

Any help will be much appreciated as I am in middle of important admob issue.... :)

Not compatible with latest OpenFL version

When I create an OpenFL project, include the admob extension and build for Android, I get the following error:

[aapt] C:\Development\Projects\AdmobTest\Export\android\bin\deps\google-pla
y-services_lib\res\values-v21\appinvite_styles.xml:5: error: Error retrieving pa
rent for item: No resource found that matches the given name '@android:style/The
me.Material.Light.DialogWhenLarge.NoActionBar'.

BUILD FAILED
C:\Development\Android SDK\tools\ant\build.xml:597: The following error occurred
while executing this line:
C:\Development\Android SDK\tools\ant\build.xml:649: The following error occurred
while executing this line:
C:\Development\Android SDK\tools\ant\build.xml:694: null returned: 1

Total time: 3 seconds

Haxelib list contains the following:

extension-admob: [1.4.7]
extension-android-support-v4: [1.0.0]
extension-googleplayservices-lib: [1.1.0]
openfl: [3.6.0]

I have the latest versions installed in the Android SDK manager of Google Play services and the Android Support Library. Am I doing something wrong or do I need another version of OpenFL?

runtime error

Here is the error I get when using extension-admob on android 4.1.2 with latest openfl (2.4.0) and lime (2.7.0) and compiled with openfl next mode:

E/dalvikvm( 7256): Could not find class 'android.support.v4.app.NotificationCompat$Builder', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
E/dalvikvm( 7256): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
E/dalvikvm( 7256): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
E/dalvikvm( 7256): Could not find class 'android.os.UserManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzap
E/dalvikvm( 7256): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzb
E/dalvikvm( 7256): Could not find class 'android.support.v4.util.SimpleArrayMap', referenced from method com.google.android.gms.ads.internal.zzq.
E/AndroidRuntime( 7256): FATAL EXCEPTION: main
E/AndroidRuntime( 7256): java.lang.NoClassDefFoundError: android.support.v4.util.SimpleArrayMap
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.zzq.(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.zzq.(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.zzb.(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.zzc.(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.zzf.(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.client.zze.zza(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.client.zzz.zzdb(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.client.zzz.zzda(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.internal.client.zzz.zza(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.BaseAdView.loadAd(Unknown Source)
E/AndroidRuntime( 7256): at com.google.android.gms.ads.AdView.loadAd(Unknown Source)
E/AndroidRuntime( 7256): at admobex.AdMobEx.reloadBanner(AdMobEx.java:243)
E/AndroidRuntime( 7256): at admobex.AdMobEx.reinitBanner(AdMobEx.java:226)
E/AndroidRuntime( 7256): at admobex.AdMobEx.(AdMobEx.java:163)
E/AndroidRuntime( 7256): at admobex.AdMobEx.getInstance(AdMobEx.java:57)
E/AndroidRuntime( 7256): at admobex.AdMobEx$1.run(AdMobEx.java:73)
E/AndroidRuntime( 7256): at android.os.Handler.handleCallback(Handler.java:632)
E/AndroidRuntime( 7256): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 7256): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 7256): at android.app.ActivityThread.main(ActivityThread.java:4777)
E/AndroidRuntime( 7256): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7256): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 7256): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
E/AndroidRuntime( 7256): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
E/AndroidRuntime( 7256): at dalvik.system.NativeStart.main(Native Method)

I checked and I have the latest version of Google Play Services (rev 28) in my SDK manager
Might be a question of correctly defining Support Library import dependencies in your lib: https://developer.android.com/tools/support-library/setup.html

Admob Fails. How do I get the errorcode log?

I don't want to burden you with the onus of figuring out why showInterstitial invokes my _onInterstitialEvent callback with a FAILED event. I don't know how to repo this and I'd rather not waste much time trying to figure out how.

All I want to know is this. You are logging the results of a failed interstitial event:

public void onAdFailedToLoad(int errorcode) {
	AdMobEx.getInstance().loadingInterstitial=false;	
	AdMobEx.getInstance().failInterstitial=true;
	reportInterstitialEvent(AdMobEx.FAILED);
	Log.d("AdMobEx","Fail to get Interstitial: "+errorcode);
}				

(https://github.com/openfl/extension-admob/blob/master/dependencies/admobex/src/admobex/AdMobEx.java#L208)

I'm running my app in -debug mode (esp doing: lime test android -debug ...) and getting practically al logcat messages in my terminal. I also placed a Haxe trace on the onInterstitialEvent in my code, so I'm seeing things like:

09-18 15:54:32.145 24190 24190 I trace   : AdmobController.hx:80: InterstitialEvent: LOADING
09-18 15:54:33.391 24190 24190 I trace   : AdmobController.hx:80: InterstitialEvent: FAILED

What I need is access to the Log.d("AdMobEx","Fail to get Interstitial: "+errorcode); message so I can get that errorcode and debug this further. Any help would be appreciated!

Cannot install Google Play services

According to latest google play services Revision 30+ google_play_services_lib is not available in the extras folder. When ever compiling for android target I'm getting an error AndroidManifest.xml not found. Is there any workaround for the issue? Any manual override?

Listening for ad events, changing the unit ID

Hi fbricker, thanks again for this extension. I had a few basic questions for you:

  • I saw the issue regarding checking to see if an ad is ready. From my understanding this is not currently implemented. Do you have a preferred way of handling this?

For example, right now I can basically only call
AdMob.showInterstitial(0);
and wait to see what happens. if the ad isn't loaded, nothing happens at all. Should I create my own 'Ad is loading' window, and time it out after X seconds? That way the user understands that the app at least tried to load an ad.

  • Related to the above question: do ads only get one chance to display on screen? If I call 'showInterstitial' and nothing happens, do I have to worry about the ad randomly showing up later?
  • Lastly, am I free to change the unit id during runtime, after it is initially set? I would like to randomize the unit id each time so I can share profits between myself and my partner. As soon as one ad is finished, can I make another call to initAndroid()/initIOS() and just pass in a new id? Not sure if this will result in unintended behavior.

Thanks!

Ad banner not displaying anymore

I have an android project that uses the openfl-admob library to display an admob banner.
This used to work correctly but since a month or so, the ad banner do not display anymore (whithout any change in the code of the class requesting it).
I have of course updated the google sdk API to the latest, so as the openfl-admob lib, but it do not fixed the issue. The problem is that I do not see any error trace message in the output console. So I really don't know what is going on. I have another android project that also use openfl-admob but for which the ad banner is correctly displayed. So I tried to use the same bannerID in both projects to see wheter the issue could be related to a wrong/deprecated ID. But the problematic project still do not display any ad whereas the other one is working correctly. Both classes that makes call to the AdMob.showBanner() are really similar in each project so I really don't understand why it is working in one and not the other. Also, I tried to replace the AdMob.showBanner() by an AdMob.showInterstitial() call but the ad do not show either. So it looks like whatever the type of ad I am trying to display, it is working in one project but not in the other.
Hence my question is: Is there any way to track in detail why the ad is not displayed? Is there a verbose mode that can be activated and show me in detail the calls the openfl-admob library is doing (to see if the ad is correctly loaded and if it is just a display problem or something else)?

Gradle problem when compiling

Hello,
I get some Gradle errors when I try to compile my android game using extension-admob

Here is what I have in my Project.xml related to this extension

<?xml version="1.0" encoding="utf-8"?>
<project>
	<!-- _________________________ Application Settings _________________________ -->

	<app title="Dodge'it" file="Esquive" main="Main" version="0.1.1" company="GrissDev." />

	<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
		or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
	<app preloader="flixel.system.FlxPreloader" />

	<!--Minimum without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2-->
	<set name="SWF_VERSION" value="11.8" />

	<!-- ____________________________ Window Settings ___________________________ -->

	<!--These window settings apply to all targets-->
	<window width="480" height="480" fps="60" background="#000000" hardware="true" vsync="false" />

	<!--HTML5-specific-->
	<window if="html5" resizable="true" width="0" height="0" />

	<!--Desktop-specific-->
	<window if="desktop" orientation="landscape" fullscreen="false" resizable="true" />

	<!--Mobile-specific-->
	<window if="mobile" orientation="portait" fullscreen="true" width="0" height="0" />

	<!-- _____________________________ Path Settings ____________________________ -->

	<set name="BUILD_DIR" value="export" />
	<classpath name="source" />
	<assets path="assets" />

	<!-- _______________________________ Libraries ______________________________ -->

	<haxelib name="flixel" />

	<!--In case you want to use the addons package-->
	<haxelib name="flixel-addons" />

	<!--In case you want to use the ui package-->
	<!--<haxelib name="flixel-ui" />-->

	<!--In case you want to use nape with flixel-->
	<!--<haxelib name="nape-haxe4" />-->

	<haxelib name="extension-admob" if="mobile"/>

	<!-- ______________________________ Haxedefines _____________________________ -->

	<!--Enable the Flixel core recording system-->
	<!--<haxedef name="FLX_RECORD" />-->

	<!--Disable the right and middle mouse buttons-->
	<!--<haxedef name="FLX_NO_MOUSE_ADVANCED" />-->

	<!--Disable the native cursor API on Flash-->
	<!--<haxedef name="FLX_NO_NATIVE_CURSOR" />-->

	<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
	<haxedef name="FLX_NO_MOUSE" if="mobile" />
	<haxedef name="FLX_NO_KEYBOARD" if="mobile" />
	<haxedef name="FLX_NO_TOUCH" if="desktop" />
	<!--<haxedef name="FLX_NO_GAMEPAD" />-->

	<!--Disable the Flixel core sound tray-->
	<!--<haxedef name="FLX_NO_SOUND_TRAY" />-->

	<!--Disable the Flixel sound management code-->
	<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->

	<!--Disable the Flixel core focus lost screen-->
	<!--<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />-->

	<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
	<haxedef name="FLX_NO_DEBUG" unless="debug" />

	<!--Enable this for Nape release builds for a serious peformance improvement-->
	<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />

	<!-- _________________________________ Custom _______________________________ -->

	<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->

	<!-- <haxedef name="analyzer-optimize" unless="desktop"/> -->
	<!-- <haxeflag value="full" name="-dce" unless="desktop"/> -->

	<android target-sdk-version="23" if="android" />
</project>

Here is the log I get :

Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Configure project :deps:admobex
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

> Task :deps:admobex:compileDebugJavaWithJavac
D:\Users\Name\Documents\Autres\Projets Haxe\Esquive\export\android\bin\deps\admobex\src\admobex\AdMobEx.java:33: error: cannot find symbol
        private InterstitialAd interstitial;
                ^
  symbol:   class InterstitialAd
  location: class AdMobEx
D:\Users\Name\Documents\Autres\Projets Haxe\Esquive\export\android\bin\deps\admobex\src\admobex\AdMobEx.java:181: error: cannot find symbol
                        builder.addTestDevice(deviceId);
                               ^
  symbol:   method addTestDevice(String)
  location: variable builder of type Builder
D:\Users\Name\Documents\Autres\Projets Haxe\Esquive\export\android\bin\deps\admobex\src\admobex\AdMobEx.java:184: error: cannot find symbol
                builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
                       ^
  symbol:   method addTestDevice(String)
  location: variable builder of type Builder
D:\Users\Name\Documents\Autres\Projets Haxe\Esquive\export\android\bin\deps\admobex\src\admobex\AdMobEx.java:187: error: cannot find symbol
                        builder.tagForChildDirectedTreatment(true);
                               ^
  symbol:   method tagForChildDirectedTreatment(boolean)
  location: variable builder of type Builder
D:\Users\Name\Documents\Autres\Projets Haxe\Esquive\export\android\bin\deps\admobex\src\admobex\AdMobEx.java:196: error: cannot find symbol
                        interstitial = new InterstitialAd(mainActivity);
                                           ^
  symbol:   class InterstitialAd
  location: class AdMobEx
Note: D:\Users\Name\Documents\Autres\Projets Haxe\Esquive\export\android\bin\deps\admobex\src\admobex\AdMobEx.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors

> Task :deps:admobex:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':deps:admobex:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 43s
21 actionable tasks: 2 executed, 19 up-to-date
Arrêt du processus de terminal "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command lime test android -final --connect 6000". Code de sortie : 1.

I installed Android Studio 4.1.1, Android SDK Platforms 30 and 19, Android SDK Build-tools 31-rc5, Android SDK Platforms-tools 31.0.2 and Android SDK Tools 26.1.1

I am using the git version of extension-admob because the Haxelib one is not up to date. I use the Haxelib version of extension-googleplayservices-basement

Android issue with focus lost after showing interstitial ad

@fbricker
it seems like the focus is not set back to main activity after showing interstitial ad on Android.

I used stopImmediatePropagation for Android back button, after showing interstitial ad, pressing back button quits the app rather than doing something else.

any clues on how to fix this?

android.permission.READ_PHONE_STATE

Just saw this extension is adding android.permission.READ_PHONE_STATE to the AndroidManifest.xml file.
Is it really necessary as, as a result, the generated apk needs a Privacy Policy URL to be published on the playstore...?
I thought admob only needs android.permission.INTERNET permission to works. So do you know why you also add the android.permission.READ_PHONE_STATE permission? Did you experience any issue without it?

EDIT:
looks like this permission is added because:
reason: com.admobex has a targetSdkVersion < 4

I set
<android target-sdk-version="23" if="android" /> in my project.xml file, as stated in the readme. So how can I have com.admobex with targetSdkVersion>=4, so that this lib do not add android.permission.READ_PHONE_STATE to my final AndroidManifest.xml file?

wrong android:value in AndroidManifest.xml

Hi fbricker

I just tried to used your admob library in my project but it crashed with the following error:

E/AndroidRuntime(32400): FATAL EXCEPTION: main
E/AndroidRuntime(32400): java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 6171000 but found 4323000. You must have the following declaration within the element:
E/AndroidRuntime(32400): at com.google.android.gms.common.GooglePlayServicesUtil.E(Unknown Source)
E/AndroidRuntime(32400): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
E/AndroidRuntime(32400): at com.google.android.gms.internal.au.a(Unknown Source)
E/AndroidRuntime(32400): at com.google.android.gms.internal.bh.bi(Unknown Source)
E/AndroidRuntime(32400): at com.google.android.gms.internal.bh.a(Unknown Source)
E/AndroidRuntime(32400): at com.google.android.gms.ads.AdView.loadAd(Unknown Source)
E/AndroidRuntime(32400): at org.haxe.lime.GameActivity.loadAd(GameActivity.java:182)
E/AndroidRuntime(32400): at org.haxe.lime.GameActivity$1.run(GameActivity.java:199)
E/AndroidRuntime(32400): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(32400): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(32400): at android.os.Looper.loop(Looper.java:153)
E/AndroidRuntime(32400): at android.app.ActivityThread.main(ActivityThread.java:4987)
E/AndroidRuntime(32400): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(32400): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(32400): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
E/AndroidRuntime(32400): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
E/AndroidRuntime(32400): at dalvik.system.NativeStart.main(Native Method)
E/AppErrorDialog( 358): Failed to get ILowStorageHandle instance

I checked the android-version contained in the AndroidManifest.xml file of the google-play-services_lib of my android-sdk folder and it as the tagg: android:versionCode="6171000" so it seems to be OK (it is the latest version anyway as I just checked it with the Android SDK manager)

Am I supposed to create an AndroidManifest.xml file for my project with a tag like that:
?
Because currently I do not have any AndroidManifest.xml defined for my project so I don't know which value lime will use when building it.

Cannot load ad

I have everything set up as described in the readme, but when I open my app, I don't see any ads, and when looking at the android console I see these messages:

04-06 20:51:24.044 14401-14401/? I/Ads: Starting ad request.
04-06 20:51:24.045 14401-14401/? I/Ads: This request is sent from a test device.
04-06 20:51:24.385 1789-15309/? W/Ads: Received error HTTP response code: 403
04-06 20:51:24.391 14401-14781/? W/Ads: There was a problem getting an ad response. ErrorCode: 0
04-06 20:51:24.392 14401-14401/? W/Ads: Failed to load ad: 0

Anyone know what the issue could be?

Primitive not found

I'm building with the latest versions of everything onto my Mac.
This seems to build and install fine but when I run my app on my iPhone (10.2) I get the following error when InitIOS is called.

Primitive not found : admobex_init__MULT
AdMob.hx:101: iOS INIT Exception: Null Function Pointer

Can the documentation be updated with a list of component versions that this extension works with, as I expect I need to downgrade something.

check if Ads are Ready (cached)

Admob has a feature to cache Ads, and a method to check if it was cached/loaded...
This is implemented in the Adobe Air / Admob too,
Do you think is possible to implement this?
Regards

some errors when id is wrong

It will be great to show some errors when id is wrong. For example I copy pasted ids with a space in front and spent a lot of time looking for errors in other places until I found that space. So may be some debug mode, disabled by default would be great.

Test mode

Is it possible to show ad in the test mode?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.