コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Play Asset Delivery を導入して Android ビルドしたら DllNotFoundException が発生

概要

DllNotFoundException: /data/app/~~EpCtMMU6o4jMa8tCi-kNiQ==/XXXX-BkCHnxel99lOtmD1A37Utg==/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Interop+Sys.LChflagsCanSetHiddenFlag()
  at Interop+Sys..cctor () [0x00000] in <7560840559c84ffbb83a08c4696f01f7>:0 
Rethrow as TypeInitializationException: The type initializer for 'Sys' threw an exception.
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.IO.File.Exists (System.String path) [0x00043] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.TimeZoneInfo.TryLoadTzFile (System.String tzFilePath, System.Byte[]& rawData, System.String& id) [0x00000] in <7560840559c84ffbb83a
????????????????????????????????????????????????????????????????????????????????
DllNotFoundException: /data/app/~~EpCtMMU6o4jMa8tCi-kNiQ==/XXXX-BkCHnxel99lOtmD1A37Utg==/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Interop+Sys.LChflagsCanSetHiddenFlag()
  at Interop+Sys..cctor () [0x00000] in <7560840559c84ffbb83a08c4696f01f7>:0 
Rethrow as TypeInitializationException: The type initializer for 'Sys' threw an exception.
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.IO.File.Exists (System.String path) [0x00043] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.TimeZoneInfo.TryLoadTzFile (System.String tzFilePath, System.Byte[]& rawData, System.String& id) [0x00000] in <7560840559c84ffbb83a
DllNotFoundException: /data/app/~~EpCtMMU6o4jMa8tCi-kNiQ==/XXXX-BkCHnxel99lOtmD1A37Utg==/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Interop+Sys.LChflagsCanSetHiddenFlag()
  at Interop+Sys..cctor () [0x00000] in <7560840559c84ffbb83a08c4696f01f7>:0 
Rethrow as TypeInitializationException: The type initializer for 'Sys' threw an exception.
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] in <7560840559c84ffbb83a08c4696f01f7>:0 
  at System.IO.File.Exists (System.String path) [0x00043] in <7560840559c84ffbb83a08c4696f01f7>:0 

Play Asset Delivery を導入して Android ビルドしたら
上記のように DllNotFoundException が発生する現象に遭遇した

System.IO.File.Exists や System.TimeZoneInfo.TryLoadTzFile を
使用している箇所で発生していた

libmono-native.so

ログを見てみると Mono2x ビルド関係のファイルで問題が起きているようだった

Mono2x ビルドではなく IL2CPP ビルドするようにしたら
DllNotFoundException が発生しなくなった

参考サイト様