Open humbertodias opened 4 years ago
Hi @humbertodias
Thank you for this, the APK works great, but I have tried to put together the Unity project and no matter what I do I get errors when I run my version on the Android device, around the dlopen within the LoadLibrary().
Works perfectly in windows build.
I have tried Mono and IL2CPP but always get either dlopen failed library "snes9x_libretro_android.so file" not found when using Mono or Undefined symbol UnityShaderCompilerExtEvent when using IL2CPP.
Compiling for Android 4.4 upwards, tried on several different devices.
I check if the file exists using WWW in unity and I get a true response and even checked the APK file and all .so files are there.
`var www = new UnityWebRequest(fileName);
if (!string.IsNullOrEmpty(www.error))
{
Debug.LogError("Cant read file");
}
else
{
Debug.Log("Core has been Found...");
}`
Fails at the below.
`Debug.Log("So Path : " + fileName);
IntPtr retVal = dlopen (fileName, RTLD_NOW);
var errPtr = dlerror ();
if (errPtr != IntPtr.Zero) {
Debug.LogError ("In the LoadLibrary Method :- " + Marshal.PtrToStringAnsi (errPtr));
}
return retVal;`
I have tried the following versions of unity.
2019.4.9f1 2018.4.7f1 2019.3.3f1 2017.1.0f3 2020.1.5
Just wondering if I am missing something in the UNITY settings / project.
Any advice would be much appreciated,
Thanks
Mike
Hello,
this is a very interesting project.
I tried to follow your instruction but I end with a white screen on the virtual TV.
On Windows, it works normally.
I put the cores .so in Plugins and assigned them with Arm7, enabled External SD Card (and I have the screen with the first boot of the app), and put the games in the StreamingAssets folder.
If I monitor errors, I get something about "no local sync point found": 4-27 14:57:53.356: E/Layer(936): [Surface(name=AppWindowToken{129ba6 token=Token{7a67101 ActivityRecord{29726e8 u0 com.scorr.retrounity/com.unity3d.player.UnityPlayerActivity t3797}}})/@0xab168a9 - animation-leash#0] No local sync point found, barrierLayer : [com.sec.android.app.launcher/com.sec.android.app.launcher.activities.LauncherActivity$_2372#0] 04-27 14:57:55.539: E/Unity(25704): at RetroUnity.LibretroWrapper+Wrapper.Init () [0x00000] in <901ff39b303e448898ca5eb888ab221c>:0 04-27 14:57:55.539: E/Unity(25704): at RetroUnity.GameManager.LoadRom (System.String romPath) [0x0003a] in <901ff39b303e448898ca5eb888ab221c>:0 04-27 14:57:55.539: E/Unity(25704): at RetroUnity.GameManager.Awake () [0x00016] in <901ff39b303e448898ca5eb888ab221c>:0
I tried on Unity 2109.4 and 2021.3.
PS : It lloks like the core is not loaded by ldopen. I tried to set the core to v7 or v8, the target to v7 or v8,, all using the v7 or v8 versions of the core.
Any ideas ?
Thank you
Nicolas
Hi @nickos64252
I am looking at this project again after a while, I will let you know if I get anything similar.
I have been trying to get it to work for VR on Quest2 but just testing on Samsung Phones at the min, but still getting the errors.
These are the 2 errors I get.
1) Mono I get :- dlopen failed library "snes9x_libretro_android.so file" not found
2) IL2CPP I get :- Undefined symbol UnityShaderCompilerExtEvent
Mike
Hi @saintmikie ,
I am doing pretty much the same thing. I want to put it on Quest/Quest 2, but currently trying to make it run an any Android device.
I have the exact same errors, but I have "unable to find libdl" just before.
For now, I guess no ".so" are loaded, but i cannot figure out why. I tried to target older API (guessing Android 10 was blocking something), but, no success.
Nicolas
Hi @saintmikie ,
I am doing pretty much the same thing. I want to put it on Quest/Quest 2, but currently trying to make it run an any Android device.
I have the exact same errors, but I have "unable to find libdl" just before.
For now, I guess no ".so" are loaded, but i cannot figure out why. I tried to target older API (guessing Android 10 was blocking something), but, no success.
Nicolas
You have to include the android liberto cores, the so-called "so" files have to include in your apk. check at the "lib" folder of your apk and "assets" for the "so" files
@lazydevyo
I put the cores "*.so" in the Plugins folder and they are present in the apk lif folder.
But I think libdl is not found and that makes them useless.
Hi,
Below is my Lib folder inside the APK.
Hi,
Could it be that they are not in the root of lib.
Mike
"sned9x_libretro_android.so" is there.. but where did you find libdl.so ?
I think I by passed that by changing [DllImport("libdl.so", EntryPoint = "dlopen")] to [DllImport("dl", EntryPoint = "dlopen")] I do not have "unable to find libdl" anymore; but the cores are still not found.
If what you do work, I would like to know your way.
I guess you downloaded libdl.so somewhere else, then added it in Plugins and configured it for Armv7.
Have you changed anything else ?
I downloaded the APK above and that works fine on my phone.
libdl.so does not seem to exist in the APK above.
Just comparing builds now.
Mike
Got a little bit further but now getting the error below.
It finds the so file, in my case I have tried 2 , snes9X_libretro_android, fuse_libretro_android, I have also made sure I am using the sames version of unity that the Github Project is set too. 2019.4.9f1.
I also use the free asset, InGameDebugConsole for unity.
I can get the windows version working fine.
Compiled out to IL2CPP and ARM64 and get the following error now.
Hello,
I succeeded to make it run and wanted to let you know.
1- libdl I changed all [DllImport("libdl.so" to [DllImport("dl" because I had error with "unable to find libdl.so"
2- core naming I had "Error loading DLL" I changed the core name by adding lib in front. Ex : snes9x_libretro_android-so -> libsnes9x_libretro_android.so (Do not forget to set only for Android platfrom and Armv7) Then added in the LoadCore function : string dllPath = "lib" + dllName + "_android.so";
3- rom path There was a problem with the rom from StreamingAsset, I loaded it directly from another persistent folder
Hope it helps
Nicolas
Hi Nicolas,
Well I am pretty positive that mine are now being found but now stuck with the Partial Byte Sequence error.
Both the libdl.so and rom are being found, but fails when reading it, I don't get the file not found anymore.
What version of Unity are you running in, I am using 2019.4.9f1 on Windows.
Maybe my libdl.so is the wrong version or something like that, or I am missing something in unity.
Mike
@saintmikie ,
I tried and succeeded on Unity 2019.4.11 and 2021.3.1
OMG, it's working.
Once changing to "dl" I had to remove the libdl from my project and it is now working, I still get the UnityShader error but it is working.
Thank you for the insperation.
Mike
Core downloader sets the core file as native and arm7![1-core-as-native-plugin](https://user-images.githubusercontent.com/9255997/92995792-ee9b8580-f506-11ea-8f6c-2be2bbe10ed6.png)
Then the shared library will be available globally inside the APK![2-apk-plugin-arm](https://user-images.githubusercontent.com/9255997/92995813-1e4a8d80-f507-11ea-8feb-baf1596d6162.png)
Enabling SD Card permission![3-unity-android-sdcard-permission](https://user-images.githubusercontent.com/9255997/92995827-2d314000-f507-11ea-89cb-e8c8f38f141f.png)
Rom inside Assets/StreamingAssets![4-rom-inside-streamingassets](https://user-images.githubusercontent.com/9255997/92995912-e728ac00-f507-11ea-90b8-b7a03b14bfc1.png)
Only for the first time you play, the permission will be asked![4-android-sdcard-permission](https://user-images.githubusercontent.com/9255997/92995861-6964a080-f507-11ea-8615-ac69f72cb757.png)
Playable![5-android-running](https://user-images.githubusercontent.com/9255997/92995875-87320580-f507-11ea-9dcb-5b84339944bb.jpg)
APK demo https://drive.google.com/file/d/144tQuoYxkcMtt7cj5X-HiPV021aKnc9f/view?usp=sharing