• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 Conditional compilation? [Solved]

J

Jayars

Guest
I'm working on a project that targets html and android.
I'm using the GooglePlayServices extension for my android target, which works fine on android.
But how do I now compile for html?

I get errors like:
Object: obj_game_start Event: Async - Social at line 14 : unable to find function "GoogleMobileAds_MoveBanner"

I think what I need here is some sort of conditional compilation.
I tried creating 2 configurations in the resource tree (android/html).
And tried checking it via os_get_config()=="android"
But when I try to compile for HTML, I get an error.

Thanks
J
 

Attachments

C

Crowstrum

Guest
I'm working on a project that targets html and android.
I'm using the GooglePlayServices extension for my android target, which works fine on android.
But how do I now compile for html?

I get errors like:
Object: obj_game_start Event: Async - Social at line 14 : unable to find function "GoogleMobileAds_MoveBanner"

I think what I need here is some sort of conditional compilation.
I tried creating 2 configurations in the resource tree (android/html).
And tried checking it via os_get_config()=="android"
But when I try to compile for HTML, I get an error.

Thanks
J
You might want to check out this post, https://forum.yoyogames.com/index.p...-gm2-android-module-setup-and-keystore.18558/
I have not built anything for a mobile device in GMS2 yet, but from prior experience this "key not found" is usually a keystore problem.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I'm assuming that the issue is that you are only exporting the Google extension on the Android platform, which means when you compile for HTML5 the referenced functions no longer exist. So, even if you don't call them because you are on the Android Config, they will still be getting checked at compile time. I believe, that what you need to do is create an HTML5 Extension, add a generic placeholder file, and then double click it to open the function properties. There, replicate all the Android extension function names (the values don't really matter). Now, when you run your game it should compile, and as long as you never actually use those functions you shouldn't have a problem.

NOTE! I may be wrong a bout this! It's ages since I've done multiplatform stuff... :)
 
J

Jayars

Guest
Thanks for the replies guys.

@Crowstrum
my android export works fine. But when I target HTML5, that's when the error pops up. I get around it by not having any configurations at all.

@Nocturne
I tried creating a new extension > Generic Placeholder > new function > "GoogleMobileAds_Init".
But it then says "Invalid Name, already in use: GoogleMobileAds_Init. Names must be unique".

So now I'm confused. On the one hand, compile fails because it is unable to find the function. But I cannot add a new extension to polyfill/placehold the function. What should I do?
 

Attachments

J

Jayars

Guest
So I figured out what needed to be done:

When I installed the GooglePlayServices extension, all the export targets were ticked.
Screenshot (70).png

What I had to do was:
1. Untick everything except Android
2. In my code, check for (os_type == os_android)

I think os_type == os_android is evaluated during compile time, and when targeting HTML5, automatically strips out the code inside (including the missing GoogleMobileAds_* functions).
Not sure though how this relates to the extension's export targets, because if I did not untick the HTML5 option, I get the same error, even with the os_type==os_android check.

Can someone clarify this for me please?

Thanks!
J
 
Top