• 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.

Android extension not working

kalzme

Member
I've followed the instructions here (written by @Nocturne) to add a simple extension but so far I haven't been able to call the methods in the extension successfully. I've tried several things but all of the methods always return undefined. Is there something I missed or is the tutorial no longer up to date with the latest verions of GM:S?

So to recap, here are the steps I did:
  1. In GM:S select Create Extension and give it a name
  2. Select Android, click next
  3. Enter the ClassName (GenericTest)
  4. Right click the newly created extension, select Add Android Source and select the folder of the javascript file
  5. Right click the extension again, select Add Placeholder > Add Generic
  6. Right click the .ext file that was created under the extension, select Properties, deselect everything except Android and Android YYC
  7. Right click the .ext file and select Add Function
  8. Enter the correct function data
Thanks in advance
 
P

PlayLight

Guest
I've followed the instructions here (written by @Nocturne) to add a simple extension but so far I haven't been able to call the methods in the extension successfully. I've tried several things but all of the methods always return undefined. Is there something I missed or is the tutorial no longer up to date with the latest verions of GM:S?

So to recap, here are the steps I did:
  1. In GM:S select Create Extension and give it a name
  2. Select Android, click next
  3. Enter the ClassName (GenericTest)
  4. Right click the newly created extension, select Add Android Source and select the folder of the javascript file
  5. Right click the extension again, select Add Placeholder > Add Generic
  6. Right click the .ext file that was created under the extension, select Properties, deselect everything except Android and Android YYC
  7. Right click the .ext file and select Add Function
  8. Enter the correct function data
Thanks in advance
Looks pretty sound to me.

returning 'undefined' could mean issues with your extension code. But if you have followed Nocturne's example to the 'T' (of course excluding the few obvious entries removed in 1.4+) then i would say that the extension class is not "accessible", which will always return 'Undefined'. The ADB log will tell you if this is the case.

Check your Java source file extension and make sure it's .java and not .js.
Double check that your class file contains the required YY-imports and is using a valid GM:S packagename.
Check that the extension functions 'external names' match the class methods.

I quickly threw together a project and wrote the Generic example extension.
Have a look through it, it might also help you pinpoint anything else you are missing.
If you want to build it, remember to check that the project build settings are valid for your setup and if not make the needed adjustments.

(please excuse the terrible codemanship, it was written rather quickly and i shall hang my head in shame later, when i have time for head hanging)
GenericTest
 
Last edited by a moderator:

ZeDuval

Member
javascript file
If this isn't just a mistake you made when writing this post, there is the problem. Java and Javascript sound related but they aren't. Actually, they share almost nothing. ;) To write Android-extensions, you'll need to use Java. You can use Javascript to write extensions for the HTML5-, Windows8- and Tizen-modules.
 

kalzme

Member
If this isn't just a mistake you made when writing this post, there is the problem. Java and Javascript sound related but they aren't. Actually, they share almost nothing. ;) To write Android-extensions, you'll need to use Java. You can use Javascript to write extensions for the HTML5-, Windows8- and Tizen-modules.
My bad! I did mean to write Java instead of JavaScript and the file is indeed a .java file. As a web developer who hasn't coded in Java for years it's hard to type the word Java without automatically adding the script in the end.

Looks pretty sound to me.

returning 'undefined' could mean issues with your extension code. But if you have followed Nocturne's example to the 'T' (of course excluding the few obvious entries removed in 1.4+) then i would say that the extension class is not "accessible", which will always return 'Undefined'. The ADB log will tell you if this is the case.

Check your Java source file extension and make sure it's .java and not .js.
Double check that your class file contains the required YY-imports and is using a valid GM:S packagename.
Check that the extension functions 'external names' match the class methods.

I quickly threw together a project and wrote the Generic example extension.
Have a look through it, it might also help you pinpoint anything else you are missing.
If you want to build it, remember to check that the project build settings are valid for your setup and if not make the needed adjustments.

(please excuse the terrible codemanship, it was written rather quickly and i shall hang my head in shame later, when i have time for head hanging)
GenericTest
Thanks, I will check this out later today! This will certainly help pinpoint the problem.
 

kalzme

Member
Looks pretty sound to me.

returning 'undefined' could mean issues with your extension code. But if you have followed Nocturne's example to the 'T' (of course excluding the few obvious entries removed in 1.4+) then i would say that the extension class is not "accessible", which will always return 'Undefined'. The ADB log will tell you if this is the case.

Check your Java source file extension and make sure it's .java and not .js.
Double check that your class file contains the required YY-imports and is using a valid GM:S packagename.
Check that the extension functions 'external names' match the class methods.

I quickly threw together a project and wrote the Generic example extension.
Have a look through it, it might also help you pinpoint anything else you are missing.
If you want to build it, remember to check that the project build settings are valid for your setup and if not make the needed adjustments.

(please excuse the terrible codemanship, it was written rather quickly and i shall hang my head in shame later, when i have time for head hanging)
GenericTest
The example you provided works very well.
However, when I export the extension and import the generated .gmez file into my project I have the same problem: the functions return undefined.
So it must be configuration then? I am using the Facebook extension in this project, might that be causing a conflict?
 
P

PlayLight

Guest
The example you provided works very well.
However, when I export the extension and import the generated .gmez file into my project I have the same problem: the functions return undefined.
So it must be configuration then? I am using the Facebook extension in this project, might that be causing a conflict?
No the generic extension is very basic and self contained. Should have no problems with any other extensions.
Could you provide the exported .gmez for me to peruse?
 

clee2005

Member
@kalzme did you ever sort this out? I am trying to put together a basic Android extension, and stripped it down to just : return "something"; in the public function and even that is still returning Undefined as you seemed to get. All naming seems correct, I have the iOS counterpart working properly. The Android export builds fine, and will fail if I mess up the .java file so it's building and taking the .java file... just not getting through to it for some reason.

EDIT : I just tried taking that single function from the .java file and sticking it in another existing (working) extension and added the function to the extension. It works. So it's the class, or .java file somehow.

PS : It's 2.1.4.212 Runtime
 
Last edited:

sman

Member
Same problem for me with GMS2. Have you found a solution?

[Edit] created a new extension with the same java file. Copied the .yy file into the previous extension. Worked... 1 day of work lost. Again. :mad:
 
Last edited:

RizbIT

Member
hi can you tell me how you got this to work?

I have two configurations both for android, but the extension i have only works with the default configuration. When i change to the second configuration and compile the extension returns undefined or blank values..i.e doesnt work


EDIT *SOLVED**
In the extension itself it was set to export to Android, but in the subtre there was a .ext file and in there you also have to set to export to Android, for some reason it wasnt for the second config
 
Top