HaxeExtension / extension-admob

OpenFL extension for "Google AdMob" on iOS and Android.
Other
58 stars 25 forks source link

Primitive not found #31

Closed ThatRobClarke closed 2 years ago

ThatRobClarke commented 7 years ago

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.

pozirk commented 7 years ago

I'm having the same problem. Were you able to fix it?

jgranick commented 7 years ago

Are you using a haxelib version, or you using the development version?

If you are using a development version, can you try and run lime rebuild extension-admob ios?

Thanks

pozirk commented 7 years ago

I'm using haxelib version, but can definitely try development one. Will let you know the results. Thank you!

pozirk commented 7 years ago

Nope, still getting the same error message..

jgranick commented 7 years ago

What was the trigger between it working and not working? Did any code change? Does this code get called after the new constructor in your Main class, or could it be that it's being statically initialized? Did you change or HXCPP versions?

In the development version, does it appear to have all iOS architecture files generated (such as arm64, armv7) or are there some missing?

pozirk commented 7 years ago

I have never tried this extension for iOS before, so my first time. Trying with the following:

extension-admob: [1.6.4] extension-googleplayservices-basement: [1.1.0] extension-googleplayservices-lib: [1.1.1] hxcpp: [3.4.64] lime: [4.0.3] openfl: [4.9.2]

After rebuild, it has all the iOS architecture files generated.

Also, I'm trying it on iOS 9.3.5, while @ThatRobClarke has the same problem on iOS 10.2. Maybe it helps. :)

pozirk commented 7 years ago

Are there any tutorials on how to make extensions for iOS? I guess, I have to look into this myself. :)

ThatRobClarke commented 7 years ago

Like @pozirk, I've never had this working as I've only started looking at this for the past few weeks.

My machine has HAXE 3.4.2 and the following haxelibs installed.

actuate: [1.8.7] extension-admob: [1.6.4] extension-googleplayservices-basement: [1.1.0] haxelib: [3.3.0] hxcpp: [3.4.64] lime-samples: [4.0.1] lime: [4.0.3] nme: [5.7.1] openfl-tools: [1.0.10] openfl: [4.9.2]

Which looks pretty much the same as the list mentioned above. I'm also building with XCode 8.3.1 on macOS Sierra.

pozirk commented 7 years ago

So, I was able to narrow down the problem to this:

private static var __init:String->String->String->Bool->Bool->Dynamic->Void = function(bannerId:String, interstitialId:String, gravityMode:String, testingAds:Bool, tagForChildDirectedTreatment:Bool, callback:Dynamic){};

Becase of the callback:Dynamic, it fires mentioned error message. After removing callback, it started to work, but this callback is important as well. So, @jgranick any ideas why this is happening?

ThatRobClarke commented 7 years ago

@pozirk I don't think taking out the callback will make this work. It just stops the error from being displayed.

pozirk commented 7 years ago

Yes, right, that's why I've checked first and it's working without callback.

pozirk commented 7 years ago

@fbricker, any help with that??? :)

mlopes commented 7 years ago

Having the same issue here with the haxelib version, pulled today (12th July) from haxelib.

pozirk commented 7 years ago

It's fixed by @grazer, just take his modifications from github and rebuild the extension.

mlopes commented 7 years ago

Hum... odd, I still get:

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

I installed the branch from which the pull request was made:

haxelib git extension-admob git@github.com:grazer/extension-admob.git bugfix-prim_multi

The file seems to be the one with the fix:

$ cat /usr/local/lib/haxe/lib/extension-admob/git/project/common/ExternalInterface.cpp
#ifndef STATIC_LINK
#define IMPLEMENT_API
#endif

#if defined(HX_WINDOWS) || defined(HX_MACOS) || defined(HX_LINUX)
#define NEKO_COMPATIBLE
#endif

#include <hx/CFFI.h>
#include "AdMobEx.h"

using namespace admobex;

AutoGCRoot* intestitialEventHandle = NULL;

static value admobex_init(value *args, int count){
    value on_interstitial_event = args[5];
    intestitialEventHandle = new AutoGCRoot(on_interstitial_event);

    const char* banner_id_str = val_string(args[0]);
    const char* interstitial_id_str = val_string(args[1]);
    const char* gravity_mode_str = val_string(args[2]);
    bool testing_ads = val_bool(args[3]);
    bool child_directed_treatment = val_bool(args[4]);

    init(banner_id_str, interstitial_id_str, gravity_mode_str, testing_ads, child_directed_treatment);

    return alloc_null();
}
DEFINE_PRIM_MULT(admobex_init);

static value admobex_banner_show(){
    showBanner();
    return alloc_null();
}
DEFINE_PRIM(admobex_banner_show,0);

static value admobex_banner_hide(){
    hideBanner();
    return alloc_null();
}
DEFINE_PRIM(admobex_banner_hide,0);

static value admobex_banner_refresh(){
    refreshBanner();
    return alloc_null();
}
DEFINE_PRIM(admobex_banner_refresh,0);

extern "C" void admobex_main () {
    val_int(0); // Fix Neko init

}
DEFINE_ENTRY_POINT (admobex_main);

static value admobex_interstitial_show(){
    return alloc_bool(showInterstitial());
}
DEFINE_PRIM(admobex_interstitial_show,0);

extern "C" int admobex_register_prims () { return 0; }

extern "C" void reportInterstitialEvent(const char* event)
{
    if(intestitialEventHandle == NULL) return;
//    value o = alloc_empty_object();
//    alloc_field(o,val_id("event"),alloc_string(event));
    val_call1(intestitialEventHandle->get(), alloc_string(event));
}

But I still get the error. The xcode version I'm using is 8.3.2 (8E2002).

grazer commented 7 years ago

Did you rebuild the extension for iOS?: lime rebuild extension-admob ios

mlopes commented 7 years ago

I had not, I've done it now, and it fixed it. Thanks. 👍