Native Extensions

I know the updates are few and far between, and I can only apologise and I hope to better our update rate :slight_smile:

The good news is that we’ve made good progress on the android support and if all goes well, we’ll have full android support in our next release (C/C++, Jar files, Java, resources)

Today we were able to build our AdMob example properly (I.e. No hacks or workarounds) through the editor for Android, and now we’ll make our admob example more presentable so that you can try it out soon (iOS + Android) for yourselves :slight_smile:

As a a Friday teaser, please enjoy a repost of the last image ^^

16 Likes

Yay! Great news. How about AAR files? Many SDKs now provide AAR instead of JAR.
And have you incorporated multidex support already or is it planned for later?

1 Like

The AAR support is in the back log, and I’ll create a ticket for the multidex support.
I believe both will be resolved after we’ve added support for all platforms.

7 Likes

I can’t find all defines for NE (for ex. DM_PLATFORM_OSX and etc)
Is it possible to add list to the documentation? It would be great!
Thanks!

1 Like

Yes, there are quite a few things we need to setup better documentation for, and all the available flags, etc is definitely amongst them. I’m going to start rolling that ball at least.

In the meantime, the current platform defines are:

  • DM_PLATFORM_OSX
  • DM_PLATFORM_IOS
  • DM_PLATFORM_ANDROID

(I won’t add the others yet, since they haven’t passed review yet)

3 Likes

So, with the release of 1.2.103, we’ve added full support for Android builds with java, jar files and resource files. I will add a simple example of this on our github today to get you going.

Until then (for those eager to jump on the boat), you can try:

  • Add .java files to your myextension/src/ folder
  • Add .jar files to your myextension/lib/armv7-android folder
  • Add JNI calls to java in your cpp source, to call your java/jar code
  • Add resource files to your myextension/res/android/res folder (for resources to be put in the R.java)
8 Likes

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