android - 在 Android Unity 上找不到 gdiplus.dll

标签 android unity-game-engine dll gdi+ aforge

我面临的问题是我在 Unity 平台上使用 AForge 库进行图像处理。我的代码在 Unity Editor 上运行,但是当我在 Android 手机上运行代码时,它会生成日志,例如

07-20 13:51:43.168 21178-21261/? D/Unity: Unable to lookup library path for 'gdiplus.dll', native render plugin support disabled.
07-20 13:51:43.169 21178-21261/? E/Unity: Unable to find gdiplus.dll
07-20 13:51:43.182 21178-21261/? D/Unity: Unable to lookup library path for 'libc', native render plugin support disabled.
07-20 13:51:43.182 21178-21261/? E/Unity: Unable to find libc
07-20 13:51:43.210 21178-21261/? E/Unity: DllNotFoundException: gdiplus.dll
                                              at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
                                            at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0 
                                          Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus
                                            at System.Drawing.Image.InitFromStream (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
                                            at System.Drawing.Image.LoadFromStream (System.IO.Stream stream, Boolean keepAlive) [0x00000] in <filename unknown>:0 
                                            at System.Drawing.Image.FromStream (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
                                            at AForge.Imaging.Image.FromFile (System.String fileName) [0x00000] in <filename unknown>:0 
                                            at Load_Scene.CropImage () [0x000a2] in /Users/taskeenashraf/Development/GUI/Assets/Scripts/Load_Scene.cs:78 
                                            at UnityEngine.Events.InvokableCall.Invoke () [0x00017] in /Users/builduser/buildslave/unity/build/Runtime/Export/Unit

我在网上搜索了很多,人们说你不能在 Android 上使用 gdiplus.dll,因为它是 Windows 原生的。但我在 MAC 上使用它的版本来运行 Unity。有没有办法解决。尝试将 dll 添加到统一插件文件夹但没有成功。将项目导出到 android studio 并在那里添加 dll 并再次构建失败。

最佳答案

Android 上没有gdiplus.dll。您不应使用任何需要 gdiplus.dll 的框架或 API,或在 Unity 中使用 Windows 窗体 API 中的任何类。这背后的原因是其中一些 API 依赖于只能在 Windows 上找到的 native 或托管 DLL。必须为其他平台完全重写它们才能使其正常工作,这是一项复杂且耗时的工作。


除非您只针对桌面平台,否则您不能将 AForge 库与 Unity 一起使用。由于您正在执行图像处理,因此您应该使用 OpenCV它支持桌面平台和移动设备,如 Android 和 iOS。使用 OpenCV 时,您必须将 C++ 代码作为插件编写,然后使用 C# 与其通信。如果您不是 C++ 程序员或想节省时间,请使用来自 assetstore 的 Unity 已经制作的 OpenCV 插件。 .

关于android - 在 Android Unity 上找不到 gdiplus.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51443225/

相关文章:

unity-game-engine - 使用 [Header ("text")] header 是否有限制?

c# - 获取 DNS TXT 记录

C++ GetProcAddress() 找不到静态类的方法

android - 在服务中创建纹理 View 时从未调用 onSurfaceTextureAvailable

android - 如何获取专辑中的轨道编号?

android - Unity3d 中的 GCM 推送通知导致 gms.iid.InstanceID classnotfound

c# - 在 C# 应用程序性能中访问 C++ 代码

android - SwipeRefreshLayout 干扰 ViewPager 中的 ScrollView

安卓相机: setSceneMode() has no effect on android V21

windows - 如何在没有 regsvr32 的情况下注册 glut32.dll?