Android Java Libraries in UE4 Game (OUYA SDK, Google Play Game Services, etc.)

I try to build UE plugin with Java support. I took the described in that thread plugin. I’m working on Mac OS witn UE 4.11.2

After fixing some errors on C++ and cs sides i see that:

mono:
MainFrameActions: Packaging (Android (ATC)): mono: ====6/17/2016 1:22:30 PM====PREPARING NATIVE CODE=================================================================
MainFrameActions: Packaging (Android (ATC)): mono:
MainFrameActions: Packaging (Android (ATC)): mono: ====6/17/2016 1:22:30 PM====UPDATING BUILD CONFIGURATION FILES====================================================
MainFrameActions: Packaging (Android (ATC)): mono: Updating project.properties, local.properties, and build.xml…
MainFrameActions: Packaging (Android (ATC)): mono: Updating project.properties, local.properties, and build.xml…
MainFrameActions: Packaging (Android (ATC)): mono:
MainFrameActions: Packaging (Android (ATC)): mono: ==== Writing new GameActivity.java file to /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/src/com/epicgames/ue4/GameActivity.java ====
MainFrameActions: Packaging (Android (ATC)): mono:
MainFrameActions: Packaging (Android (ATC)): mono: ====6/17/2016 1:22:32 PM====PERFORMING FINAL APK PACKAGE OPERATION================================================
MainFrameActions: Packaging (Android (ATC)): mono: Making .apk with Ant… (note: it’s safe to ignore javac obsolete warnings)
MainFrameActions: Packaging (Android (ATC)): mono: Duplicated project name in import. Project custom_rules defined first in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/custom_rules.xml and again in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/JavaLibs/g
oogle-play-services_lib_rev19/custom_rules.xml
MainFrameActions: Packaging (Android (ATC)): mono: Duplicated project name in import. Project custom_rules defined first in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/custom_rules.xml and again in /Users/AlekseiKanash/Projects/UE4_Plugin_Cortex_App_Store/ExampleProject/Intermediate/Android/APK/JavaLibs/d
ownloader_library/custom_rules.xml
MainFrameActions: Packaging (Android (ATC)): mono:
MainFrameActions: Packaging (Android (ATC)): mono: BUILD FAILED
MainFrameActions: Packaging (Android (ATC)): mono: /Users/AlekseiKanash/NVPACK/android-sdk-macosx/tools/ant/build.xml:649: The following error occurred while executing this line:
MainFrameActions: Packaging (Android (ATC)): mono: /Users/AlekseiKanash/NVPACK/android-sdk-macosx/tools/ant/build.xml:694: null returned: 1
MainFrameActions: Packaging (Android (ATC)): mono:
MainFrameActions: Packaging (Android (ATC)): mono: Total time: 1 second
MainFrameActions: Packaging (Android (ATC)): mono: UnrealBuildTool Exception: ERROR: /bin/sh failed with args -c ‘"/Users/AlekseiKanash/NVPACK/apache-ant-1.9.7/bin/ant" -quiet debug’
MainFrameActions: Packaging (Android (ATC)): CommandUtils.Run: Run: Took 5.701862s to run mono, ExitCode=5

I have NVPACK, 1R4, ant v 1.9.2 and gradle-2.2.1
What i did wrong?

Thanks!!

I’m facing a similar issue ,and i found this page.I want look at you suggested files but the link is invaild…can you post a new link of those files?or do you have any similar files to post ? thanks a lot

Likely you haven’t gone into your Unreal account and linked to your Github account. That will enable access to look at the referenced links.

Getting back into this. In order to compile the plugin you need to compile UE4 from source and build with that version. And then the resulting DLLs should be able to work with the retail version.

Thank you. I will try.

If you run into build errors, sometimes you need to clear out the Intermediate files and rebuild. I had to rebuild the engine from source and then rebuild the plugin when I was getting bogus compile errors. I’ll be writing documentation and posting a new UE4 plugin update this week. I’ve made a couple Unreal project examples that both use the Plugin. I even have UI Blueprint Widgets talking with the Plugin this time. I have UI touch controls on Mobile making calls to the Plugin and receiving callbacks from the Android code.

I put together the new UE4 Plugin and documentation.

I still need to figure out how to package the UE4 plugin so that it’ll work with the retail version. It’ll be interesting to know if it’s possible with the Java customizations.

Plugin distribution docs:

I did have another plugin question about the symbols that are added when compiling the C# build files.

The C# code for the build process is run on the host for the target. You wouldn’t do #if in there.

For the build.cs files you should look at the Target.Platform variable. It will be set to UnrealTargetPlatform.* (Win32, Win64, Mac, Linux, Android, IOS, TVOS, HTML5). Take a look at PhysX.Build.cs for an example.

C++ does have some platform-specific defines you can use, like #if PLATFORM_ANDROID.

I’m looking into gallery and camera access plus some custom Android UI overlays (text entry for the most part), Have all this working on iOS using objectiveC and investigating building a java plugin to get the same functionality on Android. Is this thread the state of the art in this regard?

If not where should we look these days?

If so then I’m hitting a newbie stumbling block.
I have a compiling version of the ExamplePlugin project building within my own on 4.17.2 - renamed MatchooAndroidPlugin. The java classes are not renamed, and the jar file remains the same ouya-sdk.jar file from git.

Compiling as I found out early on in my career, does not mean running!

10-02 12:28:22.382 23747 23770 V tv_ouya_console_api_MatchooController: Searching for tv/ouya/console/api/OuyaController
10-02 12:28:22.383 23747 23770 W System.err: java.lang.ClassNotFoundException: Didn’t find class “tv/ouya/console/api/OuyaController” on path: DexPathList[zip file “/data/app/com.MatchyMaximus.Matchoo-kdpUrTrZv51e2cfhGcsLGQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.MatchyMaximus.Matchoo-kdpUrTrZv51e2cfhGcsLGQ==/lib/arm, /system/fake-libs, /data/app/com.MatchyMaximus.Matchoo-kdpUrTrZv51e2cfhGcsLGQ==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]

Given I have no clue what I’m doing this state of affairs is not a surprise - any suggestions on what I’m doing wrong?

Going down the game activity approach things worked better.

I just found this tutorial which seems useful: GitHub - Hydrafox/JarTuto: I explain how to communicate with Unreal from Blueprint to C++, and from C++ to Java jar file using JNI

(Posted here as I found this thread when trying to work out how to do things).