Native Extensions

I’ve added a test project to demonstrate the full Android support here: https://github.com/defold/extension-android

It’s a simple example that demonstrates the use of Android resources, .jar files, .java files and JNI and some native functionality (vibration).

13 Likes

HI again!

This time I just wanted to let you know that we’ve started with the HTML5 support for native extensions, and we have managed to get the server to compile and link the engine. A good start. Next up is compiling the actual extensions, which should be a relatively easy task. And next after that, we’ll look into adding support for adding “.js” files into the /lib folder.

I know some of you are curious about the potential WebAssembly support, and although we won’t add it right away (we’re still on Emscripten 1.35), it doesn’t seem like it’s going to be a very big task to support it once it goes into the next Emscripten stable version.

8 Likes

Sounds great. Just to clarify, if you know, will I be able to compile the OpenAL extension or will I have to rewrite it in JavaScript?

It seems like Emscripten supports OpenAL out of the box: https://github.com/kripken/emscripten/issues/666

1 Like

I trying to make Android version of DefUnityAds, and I have a question:
I need to add some activities and permissions to manifest file, and I don’t know how to do it (I want to save simple installation like a library )
Maybe you have some tool or something for auto merge android.manifest or auto adding some library parameters to manifest?
If not then would be great to have this feature.

Yes, you have to create your own manifest at the moment, and link to it via the project settings. You should find our AndroidManifest template under the editor folders Copy Manifest

I think manifest stubs are a feature of AAR files, so hopefully we’ll get that feature later on when we add that

1 Like

Do you have any approximate estimates about implementation supports of *.aar? (just want to understand should I work with jar, or have sense to wait)

Sorry, no good estimate other than that it’ll probably happen after all platforms are supported. We rarely change the manifest though so you should be able to start using jars for now.

3 Likes

One more question:
How to use imports in java from my jar file?
For now I receive message that package not exist, but my jar file in “lib/android” folder.
(unfortunately I can’t find information about ext.manifest parameters for java sources compilation)

@Mathias_Westerdahl can you help me with it? This is my blocker for now (

I would think you should be able to just reference the package name + class in your Java file. Say you have a Jar which has the following class and package; com.agulev.MyClass, then you should be able to import it in your Java as;

import com.agulev.MyClass;
...

If this does not work, let us know and we will try to debug it here.

I try to work with alredy builded classes.jar by unity https://github.com/Unity-Technologies/unity-ads-android/releases/download/2.1.0/unity-ads.zip
It works without any problem with JNI, but for callbacks I need to create my own java classes with custom code using the same classes.jar.

When I try to
import com.unity3d.ads.UnityAds;

I recieve an error that package com.unity3d.ads does not exist.

Here’s a small update from the native extension support.
We’ve added support for HTML5 and we anticipate it being shipped in the 1.2.105 release.

As you might be aware, we are using Emscripten to generate our Html5 builds from C++. So, you’ll be able to use C++, JavaScript and JavaScript libraries which is Emscriptens glue between C++ and JavaScript.

You’ll be able to make function calls in both directions (C++ <-> JavaScript) and here is a screen shot of the simple example app, demonstrating the features:

11 Likes

We have now deployed a new build server with fixes related to Java import errors. :slight_smile:

5 Likes

“Small update”? This is awesome! When is the .105 release scheduled for? We’re still on .103, right?

7 Likes

Hopefully, the 1.2.104 should be released tomorrow, and the 105 release is scheduled for May 29’th.
(I still have some code cleanup and code reviews to go through :wink: )

8 Likes

Cool! All works good! Thank you!

6 Likes

This is osom! I wonder who;d be the first with a Defold instant game on the Facebook =]

3 Likes

I would love to - but i think instant games is still only for selected companies?

I think I tried to sign up for that before but never heard back from Facebook. Just tried the form to sign up again and it’s giving an error. ¯\_(ツ)_/¯

2 Likes

there’s a King power. Please reach out to me at oleg.pridiuk@king.com and I shall make the intro into FB so you get hooked up with FB instant games.

2 Likes