- Home /
How do you determine the Android Architecture during runtime?
I'm working on a native plugin for Android and need to determine if the processor is x86 or ARM so that I can load the corresponding library. How is the architecture determined at run-time in C# Unity code?
Answer by liortal · Jul 16, 2016 at 11:04 AM
Please see this Stack Overflow answer: http://stackoverflow.com/questions/11989629/api-call-to-get-processor-architecture
So, that totally works in Java. Unfortunately, I didn't specify, I'm trying to get it from the C# Unity code. I have one library for each architecture and need to know which library to load.
By "library" you mean a C# library? or a Java library? how are you loading it? you should be able to call that Java code from a Unity script, something like this (didn't test so bear with me): using UnityEngine;
public static class AndroidHelper
{
// Returns the system architecture
public static string GetArchitecture()
{
using (var system = new AndroidJavaClass("java.lang.System"))
{
return system.CallStatic<string>("getProperty", "os.arch");
}
}
}
Let me know if this helps :)
Your answer
Follow this Question
Related Questions
Unity 2019.3.5f1 Android Build (IL2CPP) crash Log 0 Answers
Unity Android Native Library Entry Point Not Found but ONLY on recently added functions 0 Answers
Share URL link with Android native dialog 0 Answers
android time cheat plugin problem with broadcastreceiver 1 Answer
How to use multiple unity module or unityLibrary into native android application 0 Answers