【发布时间】:2018-06-18 19:49:51
【问题描述】:
我需要做什么:
- 将 SDL2 源代码编译为 x86 和 ARM64 架构的 .so 文件
- 在 Xamarin.Android 中引用此文件
- 在我的 C# 代码中调用 SDL2 方法。
到目前为止我学到的东西:
- SDL2 需要 Java Activity 或 JNI 绑定来调用本机代码。
- 如果不以某种方式将 SDL2 库和 JNI 集成到 Xamarin.Android 项目,我将无法继续。
- 我无法解决这个问题,而且我的大脑在这个过程中被烧毁了。
我尝试过的事情:
- 过时的 GitHub 项目:
https://github.com/0x0ade/SDL2Droid-CS
https://github.com/fallahn/sdl2vs
- 这篇博文让我可以创建 C++ 代码但不使用 Xamarin
https://trederia.blogspot.com/2017/03/building-sdl2-for-android-with-visual.html
- 通过 Android Studio 运行 SDL2,它可以工作但对我没有帮助,因为我需要调用我的 C# 代码。
我没有广泛的 Xamarin 知识,所以我不知道该怎么做,我现在真的可以用另一双眼睛。 SDL2Droid-CS GitHub 项目理论上应该可以工作,但我找不到为 C# 中包含的 x86 模拟器编译该项目中使用的 SDL2 的方法。
我尝试使用 armeabiv7 libsdl2.so 编译我的代码,然后直接在我的手机上运行它。不幸的是,Visual Studio 无法对此进行调试,因此我很难实现我的代码。
接下来我尝试通过 Android Studio 调试之前编译的应用程序(使用 SDL2Droid-CS),它给了我这个错误:
06-19 00:39:55.362 13143-13143/? I/zygote64: Late-enabling -Xcheck:jni
06-19 00:39:55.474 13143-13143/SDL2Droid_CS.SDL2Droid_CS W/ActivityThread: Application SDL2Droid_CS.SDL2Droid_CS can be debugged on port 8100...
06-19 00:39:55.514 13143-13143/? W/monodroid: Creating public update directory: `/data/user/0/SDL2Droid_CS.SDL2Droid_CS/files/.__override__`
Using override path: /data/user/0/SDL2Droid_CS.SDL2Droid_CS/files/.__override__
Using override path: /storage/emulated/0/Android/data/SDL2Droid_CS.SDL2Droid_CS/files/.__override__
Trying to load sgen from: /data/user/0/SDL2Droid_CS.SDL2Droid_CS/files/.__override__/libmonosgen-2.0.so
Trying to load sgen from: /storage/emulated/0/Android/data/SDL2Droid_CS.SDL2Droid_CS/files/.__override__/libmonosgen-2.0.so
Trying to load sgen from: /storage/emulated/0/../legacy/Android/data/SDL2Droid_CS.SDL2Droid_CS/files/.__override__/libmonosgen-2.0.so
Trying to load sgen from: /data/app/SDL2Droid_CS.SDL2Droid_CS-wmPu9Ce48QdJhvYc6bPRiA==/lib/arm64/libmonosgen-2.0.so
Trying to load sgen from: /data/user/0/SDL2Droid_CS.SDL2Droid_CS/files/.__override__/links/libmonosgen-2.0.so
06-19 00:39:55.515 13143-13143/? W/monodroid: Trying to load sgen from: /system/lib/libmonosgen-2.0.so
06-19 00:39:55.515 13143-13143/? A/monodroid: cannot find libmonosgen-2.0.so in override_dir: /data/user/0/SDL2Droid_CS.SDL2Droid_CS/files/.__override__, app_libdir: /data/app/SDL2Droid_CS.SDL2Droid_CS-wmPu9Ce48QdJhvYc6bPRiA==/lib/arm64 nor in previously printed locations.
Do you have a shared runtime build of your app with AndroidManifest.xml android:minSdkVersion < 10 while running on a 64-bit Android 5.0 target? This combination is not supported.
Please either set android:minSdkVersion >= 10 or use a build without the shared runtime (like default Release configuration).
Min SDK 是 19,所以它给出的错误很奇怪。
我假设 SDL2 没有正确实施,这会导致所有这些问题。 GitHub代码有一些漏洞,上传它的人还没有活跃。
资源:
SDL2 网站: https://www.libsdl.org/
SDL2Droid GitHub 项目: https://github.com/0x0ade/SDL2Droid-CS
来自博客的 GitHub 项目: https://github.com/fallahn/sdl2vs
【问题讨论】:
标签: java c# android xamarin.android sdl