microsoft / MapsSDK-Unity

This repository contains samples, documentation, and supporting scripts for Maps SDK, a Microsoft Garage project.
MIT License
648 stars 127 forks source link

DLL not found when targeting Android on Unity 2022.2.0 #175

Closed YohanBaillot closed 2 years ago

YohanBaillot commented 2 years ago

Running on Mac Monterey 12.3.1 with Unity 2022.2.014a and targeting the Magicleap 2 device (Android compatible), we get these errors at runtime with map showing only a green base surface no elevation or map texture and these errors in logcat. Any insight?

System.DllNotFoundException: Unable to load DLL 'MicrosoftGeospatialDecompressionNative'. Tried the load the following dynamic libraries: Unable to load dynamic library 'MicrosoftGeospatialDecompressionNative' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "MicrosoftGeospatialDecompressionNative" not found 06-17 22:24:32.952 14278 14397 E Unity : at =adc=.JPEGXR_Decompress (System.IntPtr , System.Int32 , System.IntPtr , System.Int32 ) [0x00000] in <00000000000000000000000000000000>:0 06-17 22:24:32.952 14278 14397 E Unity : at =ada=.=cBa0= (System.Byte[] , System.Int32& , System.Int32& , System.Int32 ) [0x00000] in <00000000000000000000000000000000>:0 06-17 22:24:32.952 14278 14397 E Unity : at =aEc=.=cBD1= (Microsoft.Geospatial.TileId , System.Byte[] , =aD0= ) [0x00000] in <00000000000000000000000000000000>:0 06-17 22:24:32.952 14278 14397 E Unity : at =a54=.=cCf0= (Microsoft.Geospatial.TileId , System.Threading.CancellationToken ) [0x00000] in <00000000000000000000000000000000>:0 06-17 22:24:32.952 14278 14397 E Unity : at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading 06-17 22:24:32.976 14278 14396 E Unity : System.DllNotFoundException: Unable to load DLL 'MicrosoftGeospatialDecompressionNative'. Tried the load the following dynamic libraries: Unable to load dynamic library 'MicrosoftGeospatialDecompressionNative' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "MicrosoftGeospatialDecompressionNative" not found

YohanBaillot commented 2 years ago

Note that this sample runs fine on a regular Android device, it seems that only the Magicleap 2 device is not finding this library despite being configured under the same Android settings and using the same Android plugin directories. This has been brought also to the attention of Magicleap support

kircher1 commented 2 years ago

If you're using Lumin platform in Unity to build the app, the SDK has some compatibility problems with that platform. A similar issue had been raised previously, #95.

Like the exception message here, that issue was also related to the plugin used by the SDK not being compatible with Lumin.

If you're using the Android platform to build an APK, and assuming Magic Leap supports running these Android APKs, then it seems like the app should work. However, we've never tested the SDK with a Magic Leap before, and the error message itself isn't too helpful (plugin load failures I think could be due to a handful of reasons), so it's hard to say what's exactly going wrong here unfortunately.

YohanBaillot commented 2 years ago

I think I have figured out the issue. The ML2 is Android compatible but its an x86-64 device and not arm64 as most Android mobiles. After extracting the AAR file for the MicrosoftGeospatialDecompressionNative library, I can see that there is an Arm64 directory and x86 directory with the libMicrosoftGeospatialDecompressionNative.so but that SO file is x86 32bits, not x86-64, so it looks like MS needs to provide an x86-64 version. Is that something you might be able to help with Kircher1?

kircher1 commented 2 years ago

Is it possible to use an x86 build? According to the Android docs about the ABI, 64-bit devices also support their 32-bit variants..

Support for x86-64 and Android is still TBD. I'll use your other issue to track it.

kircher1 commented 2 years ago

176

YohanBaillot commented 2 years ago

So I looked into the com.microsoft.maps.unity@0.11.2 package that is added and I see some AAR libraries inside the plugins/compressionNative/Android directory and Microsoft.Maps.Unity.dll inside the plugins directory. I see the DLL is already set to support all platforns (file shows it is a PE32 executable Intel 80386 Mono/.Net assembly, for MS Windows), I am extracting MicrosoftGeospatialDecompressionNative.aar and inside I see some shared library in JNI, with one in a x86 directory. I changed the platform from any platform to android and tried to change the CPU to x86_64 (was set to x86, and file command on the file shows it is an ELF 32-bit LSB shared object, Intel 80386 dynamic linked library) and I also tried to change the directory containing it from x86 to x86-64, but nothing works. Is that all that seem to be necessary? I am still getting this logcat error

06-26 00:06:48.158 24245 24281 E Unity : DllNotFoundException: Unable to load DLL 'MicrosoftGeospatialDecompressionNative'. Tried the load the following dynamic libraries: Unable to load dynamic library 'MicrosoftGeospatialDecompressionNative' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "MicrosoftGeospatialDecompressionNative" not found 06-26 00:06:48.158 24245 24281 E Unity : at =aD4=.ZSTD_freeDCtx (System.IntPtr ) [0x00000] in <00000000000000000000000000000000>:0 06-26 00:06:48.158 24245 24281 E Unity : at =aD9=.=cBaC= () [0x00000] in <00000000000000000000000000000000>:0 06-26 00:06:48.158 24245 24281 E Unity : at =aD9=.Finalize () [0x00000] in <00000000000000000000000000000000>:0

Could the issue be with the DLL being Mono/.Net assembly, for MS Windows? Should it be targeted for Android specifically possibly?

YohanBaillot commented 2 years ago

Wanted to let you know that after many attempts to start from a new project and clearing the Library folder after testing some of those alternatives it seems it finally worked. So I can now see terrain texture data in ML2 with the materials for the URP add-on. However the buildings areas are not showing / show very low resolution without 3D buildings, so there might still be some issues there

kircher1 commented 2 years ago

Interesting investigation. If you are seeing 3D buildings (e.g. Space Needle in Seattle) without errors, then the data seems to be flowing correctly. You may try adjusting the Detail Offset under the Quality Settings if the buildings are too low resolution.

What I meant to suggest before was enabling only x86 under the Target Architectures in the Android player settings. I wonder if by disabling x86-64, Android will fall back to the x86 version, which then should be supported by the native decompression library used by the SDK.

YohanBaillot commented 2 years ago

Thanks Ill check the x86 fall back trick later, however I doubt that would make a difference since this already work but ill see . I meant that the map does not show any building or elevation however, it shows only flat textured terrain, so no building. In area with building or terrain elevation it looks like we see only black or the lowest resolution terrain texture

On Mon, Jun 27, 2022 at 10:52 AM kircher1 @.***> wrote:

Interesting investigation. If you are seeing 3D buildings (e.g. Space Needle in Seattle) without errors, then the data seems to be flowing correctly. You may try adjusting the Detail Offset under the Quality Settings if the buildings are too low resolution.

What I meant to suggest before was enabling only x86 under the Target Architectures in the Android player settings. I wonder if by disabling x86-64, Android will fall back to the x86 version, which then should be supported by the native decompression library used by the SDK.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/MapsSDK-Unity/issues/175#issuecomment-1167675556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFNI5OIG3A7TOOGQXERDYLVRHS6LANCNFSM5ZDTGXBQ . You are receiving this because you authored the thread.Message ID: @.***>

--


Yohan Baillot LinkedIn www.linkedin.com/in/yohanbaillot Conference call link http://whereby.com/arcortex or https://us04web.zoom.us/j/2119797651

ARCortex CEO and Founder Expert Augmented Reality visualization consulting www.arcortex.com ARCortex Presentation http://www.arcortex.com/ARCortexINC.pdf ARCortex Youtube http://bit.ly/ARCortexYoutube Enabling Long Range Augmented Reality today http://www.arcortex.com/EnablingLongRangeAR.pdf

OpenARCloud Board advisor www.openarcloud.org

YouTube www.youtube.com/channel/UCI_a22gRQ28JjcjlmwwJ34A

Blog medium.com/openarcloud

Schedule a meeting https://calendly.com/arcortex

ColinYaoH1 commented 2 years ago

Hi @YohanBaillot - would you mind sharing what you did in the end to get the MicrosoftGeospatialDecompressionNative .dll to load properly?

I went through and tried what you listed above but to no success unfortunately. Appreciate any tips you can give :)

YohanBaillot commented 2 years ago

I had to uncompress the jar file for android, copy some of the windows for x86 so libraries in it and then drop the directory structure in Unity. Hope this helps

Sent from my iPhone

On Sep 4, 2022, at 14:01, ColinYaoH1 @.***> wrote:

 Hi @YohanBaillot - would you mind sharing what you did in the end to get the MicrosoftGeospatialDecompressionNative .dll to load properly?

I went through and tried what you listed above but to no success unfortunately. Appreciate any tips you can give :)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

YohanBaillot commented 1 year ago

Kircher,

The MagicLeap team is interested in discussing this further with you to see how the plugin could support ML2 out of the box. Could you please DM your contact info at @.***?

thank you

Yohan

On Mon, Jun 27, 2022 at 10:52 AM kircher1 @.***> wrote:

Interesting investigation. If you are seeing 3D buildings (e.g. Space Needle in Seattle) without errors, then the data seems to be flowing correctly. You may try adjusting the Detail Offset under the Quality Settings if the buildings are too low resolution.

What I meant to suggest before was enabling only x86 under the Target Architectures in the Android player settings. I wonder if by disabling x86-64, Android will fall back to the x86 version, which then should be supported by the native decompression library used by the SDK.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/MapsSDK-Unity/issues/175#issuecomment-1167675556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFNI5OIG3A7TOOGQXERDYLVRHS6LANCNFSM5ZDTGXBQ . You are receiving this because you authored the thread.Message ID: @.***>

--


Yohan Baillot LinkedIn www.linkedin.com/in/yohanbaillot Conference call link http://whereby.com/arcortex or https://us04web.zoom.us/j/2119797651

ARCortex CEO and Founder Expert Augmented Reality visualization consulting www.arcortex.com ARCortex Presentation http://www.arcortex.com/ARCortexINC.pdf ARCortex Youtube http://bit.ly/ARCortexYoutube Enabling Long Range Augmented Reality today http://www.arcortex.com/EnablingLongRangeAR.pdf

OpenARCloud Board advisor www.openarcloud.org

YouTube www.youtube.com/channel/UCI_a22gRQ28JjcjlmwwJ34A

Blog medium.com/openarcloud

ColinYaoH1 commented 1 year ago

+1 for the out of the box Magic Leap 2 support, would be amazing to see! :)

YohanBaillot commented 1 year ago

Hello Kircher / MS Garage, would you please DM me or let us know here a good contact info for the MS Maps SDK lead so we can discuss this further?

thanks

Yohan

On Mon, Oct 17, 2022 at 1:16 PM yohan baillot @.***> wrote:

Kircher,

The MagicLeap team is interested in discussing this further with you to see how the plugin could support ML2 out of the box. Could you please DM your contact info at @.***?

thank you

Yohan

On Mon, Jun 27, 2022 at 10:52 AM kircher1 @.***> wrote:

Interesting investigation. If you are seeing 3D buildings (e.g. Space Needle in Seattle) without errors, then the data seems to be flowing correctly. You may try adjusting the Detail Offset under the Quality Settings if the buildings are too low resolution.

What I meant to suggest before was enabling only x86 under the Target Architectures in the Android player settings. I wonder if by disabling x86-64, Android will fall back to the x86 version, which then should be supported by the native decompression library used by the SDK.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/MapsSDK-Unity/issues/175#issuecomment-1167675556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFNI5OIG3A7TOOGQXERDYLVRHS6LANCNFSM5ZDTGXBQ . You are receiving this because you authored the thread.Message ID: @.***>

--


Yohan Baillot LinkedIn www.linkedin.com/in/yohanbaillot Conference call link http://whereby.com/arcortex or https://us04web.zoom.us/j/2119797651

ARCortex CEO and Founder Expert Augmented Reality visualization consulting www.arcortex.com ARCortex Presentation http://www.arcortex.com/ARCortexINC.pdf ARCortex Youtube http://bit.ly/ARCortexYoutube Enabling Long Range Augmented Reality today http://www.arcortex.com/EnablingLongRangeAR.pdf

OpenARCloud Board advisor www.openarcloud.org

YouTube www.youtube.com/channel/UCI_a22gRQ28JjcjlmwwJ34A

Blog medium.com/openarcloud

--


Yohan Baillot LinkedIn www.linkedin.com/in/yohanbaillot Conference call link http://whereby.com/arcortex or https://us04web.zoom.us/j/2119797651

ARCortex CEO and Founder Expert Augmented Reality visualization consulting www.arcortex.com ARCortex Presentation http://www.arcortex.com/ARCortexINC.pdf ARCortex Youtube http://bit.ly/ARCortexYoutube Enabling Long Range Augmented Reality today http://www.arcortex.com/EnablingLongRangeAR.pdf

OpenARCloud Board advisor www.openarcloud.org

YouTube www.youtube.com/channel/UCI_a22gRQ28JjcjlmwwJ34A

Blog medium.com/openarcloud