grpc library를 찾지 못하는 문제

Kim suho·2021년 12월 30일
0

C# grpc를 unity에 붙이면 mac에서는 잘 돌지만 안드로이드에 올리면 아래와 같은 에러를 내면서 동작하지 않는다.
so 파일이 있는걸을 확인했는데, 자세히보니 x86_64용 library를 원하고 있다. 안드로이드는 arm64라서 어딘가 architecture 정보를 못가져와서 일어난 결과라고 판단할 수 있다.

2021-05-28 17:16:25.345 32510-2457/ai.umos.unityfragment E/Unity: FileNotFoundException: Error loading native library. Not found in any of the possible locations: /system/bin/libgrpc_csharp_ext.x64.so,/system/bin/runtimes/linux-x64/native/libgrpc_csharp_ext.x64.so,/system/bin/../../runtimes/linux-x64/native/libgrpc_csharp_ext.x64.so
      at Grpc.Core.Internal.UnmanagedLibrary.FirstValidLibraryPath (System.String[] libraryPathAlternatives) [0x00000] in <00000000000000000000000000000000>:0 
      at Grpc.Core.Internal.UnmanagedLibrary..ctor (System.String[] libraryPathAlternatives) [0x00000] in <00000000000000000000000000000000>:0 
      at Grpc.Core.Internal.NativeExtension.LoadNativeMethodsUsingExplicitLoad () [0x00000] in <00000000000000000000000000000000>:0 
      at Grpc.Core.Internal.NativeExtension..ctor () [0x00000] in <00000000000000000000000000000000>:0 
      at Grpc.Core.Internal.NativeExtension.Get () [0x00000] in <00000000000000000000000000000000>:0 
      at Grpc.Core.Internal.NativeMethods.Get () [0x00000] in <00000000000000000000000000000000>:0 
      at Grpc.Core.GrpcEnvironment.Grpc

grpc core package의 소스를 살펴보니 .net 환경변수로부터 아키텍처, os등을 읽어서 가져오게 되어 있는데 안드로이드에서 가져오지 못하는 것이었네요.
따라서 안드로이드에서도 가져올 수 있게 이를 기술해줄 필요가 있네요.
아래처럼 Assets/link.xml에 property를 넣어주면 잘 인식됩니다.

Assets/link.xml
<linker>
    <assembly fullname="UnityEngine">
        <type fullname="UnityEngine.Application" preserve="fields">
            <property name="platform"/>
        </type>
    </assembly>
</linker>
profile
평범한 개발자

0개의 댓글