Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Is Android possible in the near future? #73

Open
demonixis opened this issue Apr 28, 2019 · 11 comments
Open

Is Android possible in the near future? #73

demonixis opened this issue Apr 28, 2019 · 11 comments

Comments

@demonixis
Copy link

Hello,

The plugin works well on the Windows platform. Can we expect an Android compatiblity in a near future? What do you need to make it possible? Can we help you? If yes how?

@pixeltris
Copy link
Owner

pixeltris commented Apr 28, 2019

I haven't tried Android yet but it shouldn't be too much work to support it. Currently I don't have any phones to test this so I'm not sure how much I can do.

A starting point would be to add Android as a whitelisted platform https://github.com/pixeltris/USharp/blob/master/USharp.uplugin and see if USharp compiles.

@demonixis
Copy link
Author

Well the first step could be to make a mobile build to generate a single APK file. I can do that because I've a working setup.

@pixeltris
Copy link
Owner

Are there any Android emulators / simulators which work well with UE4? There are some issues which have popped up on Mac builds which may impact Linux / Android so I'll try out an emulator once I have fixed the Mac issues.

@demonixis
Copy link
Author

Yes, when you install Android Studio, you've an emulator with it. This way you can build an APK from UE4 and then send it to the emulator to try it. I'm going to try to make a build tomorrow on at office. Cross finger it'll be OK. For now I've enabled the Android platform in the uplugin as suggested in your first reply.

@demonixis
Copy link
Author

I tried to compile a simple scene with that result

UATHelper: Packaging (Android (ASTC)): Running AutomationTool...
UATHelper: Packaging (Android (ASTC)): Parsing command line: -ScriptsForProject="C:/Users/demon/Documents/Unreal Projects/USharpMobile/USharpMobile.uproject" BuildCookRun -nocompile -nocompileeditor -installed -nop4 -project="C:/Users/demon/Documents/Unreal Projects/USharpMobile/USharpMobile.uproject" -cook -stage -archive -archivedirectory=D:/demon/Download
s -package -clientconfig=Development -ue4exe="D:\Devel\Epic Games\UE_4.22\Engine\Binaries\Win64\UE4Editor-Cmd.exe" -pak -prereqs -nodebuginfo -targetplatform=Android -cookflavor=ASTC -build -utf8output
UATHelper: Packaging (Android (ASTC)): Setting up ProjectParams for C:\Users\demon\Documents\Unreal Projects\USharpMobile\USharpMobile.uproject
UATHelper: Packaging (Android (ASTC)): USharpMobile.uproject requires a temporary target.cs to be generated (USharp plugin is enabled)
UATHelper: Packaging (Android (ASTC)): ********** BUILD COMMAND STARTED **********
UATHelper: Packaging (Android (ASTC)): Running: D:\Devel\Epic Games\UE_4.22\Engine\Binaries\DotNET\UnrealBuildTool.exe USharpMobile Android Development -Project="C:\Users\demon\Documents\Unreal Projects\USharpMobile\USharpMobile.uproject"  "C:\Users\demon\Documents\Unreal Projects\USharpMobile\USharpMobile.uproject" -NoUBTMakefiles  -remoteini="C:\Users\demo
n\Documents\Unreal Projects\USharpMobile" -skipdeploy -Manifest="C:\Users\demon\Documents\Unreal Projects\USharpMobile\Intermediate\Build\Manifest.xml" -NoHotReload -log="C:\Users\demon\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+Devel+Epic+Games+UE_4.22\UBT-USharpMobile-Android-Development.txt"
UATHelper: Packaging (Android (ASTC)):   PLATFORM_ANDROID_NDK_VERSION = 140200
UATHelper: Packaging (Android (ASTC)):   NDK toolchain: r14b, NDK version: 19, GccVersion: 4.9, ClangVersion: 3.8.275480
UATHelper: Packaging (Android (ASTC)):   Parsing headers for USharpMobile
UATHelper: Packaging (Android (ASTC)):     Running UnrealHeaderTool "C:\Users\demon\Documents\Unreal Projects\USharpMobile\USharpMobile.uproject" "C:\Users\demon\Documents\Unreal Projects\USharpMobile\Intermediate\Build\Android\USharpMobile\Development\USharpMobile.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -Warni
ngsAsErrors -installed
UATHelper: Packaging (Android (ASTC)):   Reflection code generated for USharpMobile in 11,2493995 seconds
UATHelper: Packaging (Android (ASTC)):   ERROR: Missing precompiled manifest for 'USharp'. This module was most likely not flagged for being included in a precompiled build - set 'PrecompileForTargets = PrecompileTargetsType.Any;' in USharp.build.cs to override.
PackagingResults: Error: Missing precompiled manifest for 'USharp'. This module was most likely not flagged for being included in a precompiled build - set 'PrecompileForTargets = PrecompileTargetsType.Any;' in USharp.build.cs to override.
UATHelper: Packaging (Android (ASTC)): Took 23,8392524s to run UnrealBuildTool.exe, ExitCode=5
UATHelper: Packaging (Android (ASTC)): ERROR: UnrealBuildTool failed. See log for more details. (C:\Users\demon\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+Devel+Epic+Games+UE_4.22\UBT-USharpMobile-Android-Development.txt)
UATHelper: Packaging (Android (ASTC)):        (see C:\Users\demon\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+Devel+Epic+Games+UE_4.22\Log.txt for full exception trace)
PackagingResults: Error: UnrealBuildTool failed. See log for more details. (C:\Users\demon\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+Devel+Epic+Games+UE_4.22\UBT-USharpMobile-Android-Development.txt)
UATHelper: Packaging (Android (ASTC)): AutomationTool exiting with ExitCode=5 (5)
UATHelper: Packaging (Android (ASTC)): BUILD FAILED
PackagingResults: Error: Unknown Error

Any ideas? I'll investigate to see if I can found something.

@demonixis
Copy link
Author

demonixis commented Apr 29, 2019

Hey,
I've more news about my build error. The USharp.Build.cs was made for the Desktop platform. We need two things to make it work on Android.

  1. Add Xamarin support (it's basically Mono for Android and iOS)
  2. Edit USharp.Build.cs and add if (Target.Platform == UnrealTargetPlatform.Android) with the required code

Xamarin is now open source and can be installed on Windows et Mac (not sure about Linux). On Windows it's installed from Visual Studio Installer.

@pixeltris
Copy link
Owner

I'm not sure Xamarin should actually be required. Xamarin includes all of the APIs required to interact with Android/iOS, but a regular embedded Mono solution should work just fine (without additional bloat that might come from Xamarin). Doing it the embedded way might need Mono to be compiled manually for Android though.

Based on the USharp.Build.cs error it sounds like it just needs some changes to PrecompileForTargets? I'm not too sure what that is but it wouldn't hurt to try changing it for UnrealTargetPlatform.Android.

@pixeltris
Copy link
Owner

#76 this issue might stifle Android support. I haven't tried Linux yet but currently Mac is broken due to this issue. There is a good chance all Unix-like platforms are impacted. Unfortunately the only thing I can think of is some attempt at manually fixing the register mismatch, or engine modifications.

@pixeltris
Copy link
Owner

pixeltris commented May 4, 2019

For the build.cs error you just need to recompile the C++ after adding Android to the .uplugin file.

You can get the Mono .so files for Android from a Xamarin install or download a Xamarin archive from here https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/ and grab the .so files which are under bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\lib\armeabi-v7a

To get Mono to build for Android manually you need to follow the steps here https://github.com/mono/mono/tree/master/sdks, it's fairly straight forward. I used Linux, grabbed a version of Mono from https://download.mono-project.com/sources/mono/ (think these versions don't contain the sdks folder so you will need to copy that from github). Then ran the commands on the sdks page. Some things didn't build but all that matters is the libmonosgen-2.0.so (and the other .so files) under /sdks/out/android-armeabi-v7a-release/lib/)

I still need to write some additional code to handle loading of Mono under Android as the C# game dlls / Mono are currently being packaged into a .obb file which gets mounted to a virtual UE4 file system and therefore Mono cannot operate properly from it.

@demonixis
Copy link
Author

That's awesome! The Android platform will be a great addition to this plugin.

@pixeltris
Copy link
Owner

d23b0e3 this commit adds basic Mono loader functionality. It has to copy all of the Mono files / .NET game assemblies out of the apk so that Mono can function as expected (at the moment it will just freeze at the splash screen while it does this. it can also take up a lot of disk space). Much more work would be required to load assemblies directly from the apk (Xamarin.Android does this https://github.com/xamarin/xamarin-android/tree/master/src/monodroid/jni).

I have tested the C# Puzzle template project and it seems to work. To test this you need to add Android to the USharp.uplugin file, then create the folder structure as follows:

  • /USharp/Binaries/Managed/Runtimes/Mono/Android/bin
  • /USharp/Binaries/Managed/Runtimes/Mono/Android/etc
  • /USharp/Binaries/Managed/Runtimes/Mono/Android/lib
  • /USharp/Binaries/Managed/Runtimes/Mono/Android/lib/mono

Grab Xamarin from https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/

  • In the bin folder put libmonosgen-2.0.so (from the Xamarin files bin/Release/lib/xamarin.android/xbuild/Xamarin/Android/lib/armeabi-v7a).
  • In the lib folder put all the .NET assemblies (from the Xamarin files bin/Release/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0)
  • In the lib/mono folder put in all of the .so files (from the Xamarin files bin/Release/lib/xamarin.android/xbuild/Xamarin/Android/lib/armeabi-v7a). You might also need to copy that 'v1.0' folder here also (I need to look into the probing locations to avoid file duplication).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants