Import some dependencies for Android

With regard to foreign code, I would like to ask a question. Of course we would have to use foreign code to link between Fuse and the native platform. However my plan is that I would write up a native library for its own and then let foreign code import the relevant modules. As per my knowledge I know that in the build settings I may have some tweaks for it, but it does now show whether I can perhaps make a plain old Android project firstly and change the build settings like Gradle directly. Therefore I am not sure whether I could write codes within a plain old Android project and then link via foreign code. I am wondering if I would need to build a library in another project and then package it as a library and let Fuse to use Gradle to download that module.

my plan is that I would write up a native library for its own and then let foreign code import the relevant modules.

Sounds ideal!

in the build settings I may have some tweaks for it

It depends what kind of tweaks. You can easy add entries to the dependencies & repositories in the ‘top level’ build.gradle file & also depenencies to the ‘app module’ build.gradle file.

We also automatically tell gradle to include any jar in the app/src/main/libs folder. So Then we only need to copy the jar into the folder on build (and that is easy to do with UXL)

In summary your project seems very possible but feel free to explain the details of the build details and I’ll have a look to see if there is anything that may cause issues.

Hi Chris just now you said that Fuse would “automatically tell gradle to include” include jar in the app/src/main/libs, so do you mean that this is a default configuration or do we have to do something with UXL?

Sorry I wasn’t very clear. When you build fuse makes an android project under the build/Android/Debug/ folder. Android projects can have a libs folder in app/src/main. So the fullpath would be <YourAppName>/build/Android/Debug/app/src/main/libs. if you put a jar in there it will be included in the build.

Now doing that by hand every build would suck so we wan to use some UXL to copy that file from your project directory into that lib/ directory for us.

Make a file called whatever.uxl in your project and inside add the following:

<Extensions Backend="CPlusPlus" Condition="Android">
	<CopyFile Condition="Android" Name="yourLovelyLib.jar" TargetName="app/src/main/libs/google-yourLovelyLib.jar" />
</Extensions>

And then this your jar will be copied into the libs folder during the build, which will add it to the build itself[0].

Hope this helps!

[0] If you are curious to how this is done in gradle you can browse to <YourAppName>/build/Android/Debug/app/build.gradle and check you should see the compile fileTree(dir: 'src/main/libs', include: ['*.jar']) line in the dependencies section at the top :slight_smile: