I am referring to the Getting Started: Android Development guide.
I’d like to see more documentation around some key things.
In my case I need to be able to alter the AndroidManfest.xml to add an intent filter to show in the OUYA play section.
I’m able to build and run Unreal Engine 4.5.1 on the OUYA with File->Package Project->Android->Android (DXT).
I’d like to add a category to the activity’s intent-filter list like this.
Maybe there’s a way to add a configuration? Otherwise the alternative is to unpack the build with apktool to edit the manifest. That workaround is not ideal, it would be great to build it correctly the first time.
APK size building a scene with a camera, light, and cube comes out to be 54MB. Any documentation on how to turn on build stripping to get the size down would be ideal.
JNI - I’m looking for documentation on how to include the ouya-sdk.jar into the Unreal build. In addition to that an Android sample that uses JNI (finding Java classes in C++ and hooking the JNI_Onload routines) would be super helpful.
Here’s an example of what that looks like:
“JNI_OnLoad” is the entry point when a native library is loaded. You have a single opportunity to cache your Java classes so they can be invoked from C++.
From JNI_Onload that gives me access to add in-app-purchasing access for the OUYA. I use that to get product details, make purchases, check receipts, etc.
Most of the standard Android customizations can be done in the install folder, I.e. C:\Program Files\Unreal\Epic Games\4.5\Engine\Build\Android\Java
** Just personal preference, but I really try to avoid making changes to “Program Files” folders when making plugins. Ideally these Java customizations that follow will be part of the Unreal Project in the future.*
Epic Games\4.5\Engine\Build\Android\Java\AndroidManifest.xml - Here the package name can be customized.
The custom icons can be placed in: Epic Games\4.5\Engine\Build\Android\Java\res\drawable\app_icon.png Epic Games\4.5\Engine\Build\Android\Java\res\drawable-xhdpi\ouya_icon.png
The signing key can be placed in: Epic Games\4.5\Engine\Build\Android\Java\assets\key.der
The OUYA SDK can be placed in: Epic Games\4.5\Engine\Build\Android\Java\libs\ouya-sdk.jar
The native plugin can be placed in: Epic Games\4.5\Engine\Build\Android\Java\libs\armeabi\lib-ouya-ndk.so Epic Games\4.5\Engine\Build\Android\Java\libs\x86\armeabi-v7a Epic Games\4.5\Engine\Build\Android\Java\libs\x86\lib-ouya-ndk.so
Edit Epic Games\4.5\Engine\Build\Android\Java\libs\Android.mk to add the native library:
LOCAL_MODULE := -ouya-ndk
LOCAL_SRC_FILES := lib-ouya-ndk.so
Loading the native library can be called from: Epic Games\4.5\Engine\Build\Android\Java\src\com\epicgames\ue4\GameActivity.java
Placing files into the following folders includes as expected:
Placing the ouya-sdk.jar gets dexified
Placing the Native library put one in the jni folder so the build process completes:
And then put one in the standard Android place:
And then you’ll see the JNI_OnLoad fire as expected:
I’ve needed to run the TADP 2.X version that comes with Unreal. Unfortunately this version is limited as it doesn’t setup my Visual Studio properly with the templates needed for Android development. Of course it’s the only way to get File->Package in Unreal to work with this 2.X version.
I’ve found I need to rebuild the Solution->Engine->UE4 in Visual Studio to regenerate the code that builds libUE4.so.
Is there a faster way to make changes and a specific project I can rebuild versus rebuilding the entire editor?
Also another note:
LaunchPrivatePCH.h needs to be the first include in any cpp files that you add to the libUE4.so.
This is a faster way to at least find your native C++ compiler mistakes faster:
UnrealBuildTool.exe VirtualController Android Development C:\ouya-sdk-examples\Unreal\VirtualController\VirtualController.uproject -noxge
I’ve also seen the Unreal build output doesn’t give you a nice stack trace for Java compile errors. But you can import the immediate files into an Eclipse Android project:
And copy from: C:\ouya-sdk-examples\Unreal\VirtualController\Intermediate\Android\APK\google-play-services_lib_rev19\libs\google-play-services.jar
To isolate any Java errors that might be coming up.
Success in my end though.
Now I have native input passed to Java, remapped, and the remapped input is sent back to Unreal native code.
Now it’s time to learn how to hook up BluePrints to C++ code…