Unity free with Android native code?

Hey all,

I think it’s excellent that Android exports are now supported in the free version - does this also allow the ability use native code?

I’ve added my library objects to Assets->Plugins->Android and attempted to import them but I get an error:

Assets/TestFile.cs(15,10): error CS0246: The type or namespace name `DllImport’ could not be found. Are you missing a using directive or an assembly reference?

Should this work on the Android export enabled free version of Unity?

Edit: As always, minutes after posting I find I was missing an “using System.Runtime.InteropServices;” … My dll import error has now gone… Haven’t got anything working yet so the question still remains if native code is supported…

It seems that the .so file is in the apk in the folder lib/armeabi-v7a/ but the DllNotFoundException is trying to load it in lib/ not armeabi-v7a…

What’s going on here?

Plugins are Pro only.

Thanks for your reply mslinklater…

I was hoping that it would work since this page: Unity - Manual: Plug-ins

suggests it’s a “Pro/Mobile-Only Feature”

My mistake. Yes, plugins should work with mobile.

Hmm, I still can’t get it to see my library - I keep getting DllNotFoundException when running on an Android device.

The library I’m loading depends on a second library (which is included as a libXXX.so) - I’ve seen some mention of people having issues with library ‘chaining’ is this still an issue with Unity? If so are there any workarounds?

library chaining is a pretty big troublemaker.
This is not a unity problem but one of ‘who defines the search context’.
Unity as any application will search for it in a single predefined place + the global $path folders yet the other library might assume a path relative to something else.

The general solution is to either add the library folder to $path or to move the library there, unsure though if either of the two can work on android.

Thanks Dreamora,

Yeah, I can’t see the general solution working for android.

Seem I will need to package all native code into one .so…

A bit limiting… is there a better way?