libgit2 / libgit2/libgit2sharp.nativebinaries

Failing to load shared library 'git2-a418d9d' on android/arm64v8a

未关闭
#158 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
PowerShell
星标
35
派生
74
PR 合并指标
30 天内没有已合并 PR

描述

I am running a .NET 8 Maui Application on Android 13 (API Level 33) with architecture arm64v8a

In my app i am utilising the nuget package "LibGit2Sharp 0.30.0" that has a transitive reference to "LibGit2Sharp.NativeBinaries 2.0.322".

Upon calling Repository.Init("path/to/my/repo") my app crashes:

System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: git2-a418d9d
   at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.Proxy.git_repository_init_ext(FilePath workdirPath, FilePath gitdirPath, Boolean isBare)
   at LibGit2Sharp.Repository.Init(String path, Boolean isBare)
   at LibGit2Sharp.Repository.Init(String path)

logcat output when executing the Repository.Init method:

[monodroid-assembly] Shared library 'git2-a418d9d' not loaded, p/invoke 'git_repository_init_ext' may fail
[monodroid-assembly] Shared library 'kernel32' not loaded, p/invoke 'LoadLibrary' may fail
[monodroid-assembly] Shared library 'libdl' not loaded, p/invoke 'dlopen' may fail
[monodroid-assembly] Shared library 'git2-a418d9d' not loaded, p/invoke 'git_libgit2_init' may fail
[monodroid-assembly] Shared library 'git2-a418d9d' not loaded, p/invoke 'git_openssl_set_locking' may fail
[monodroid-assembly] Shared library 'git2-a418d9d' not loaded, p/invoke 'git_libgit2_init' may fail

I checked the contents of my *.apk file and could correctly locate libgit2-a418d9d.so under lib/arm64-v8a

also the provided lib in the nuget seems to be of correct format/architecture:

$file libgit2-a418d9d.so

libgit2-a418d9d.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=91bb85cb63fc4326cd958916c059432d51053d31, not stripped

dependencies of the lib:

$ objdump -p libgit2-a418d9d.so

libgit2-a418d9d.so:     file format elf64-little

Program Header:
    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**16
         filesz 0x000000000015f708 memsz 0x000000000015f708 flags r-x
    LOAD off    0x0000000000160660 vaddr 0x0000000000170660 paddr 0x0000000000170660 align 2**16
         filesz 0x0000000000006680 memsz 0x0000000000006db8 flags rw-
 DYNAMIC off    0x0000000000161820 vaddr 0x0000000000171820 paddr 0x0000000000171820 align 2**3
         filesz 0x0000000000000200 memsz 0x0000000000000200 flags rw-
    NOTE off    0x00000000000001c8 vaddr 0x00000000000001c8 paddr 0x00000000000001c8 align 2**2
         filesz 0x0000000000000024 memsz 0x0000000000000024 flags r--
EH_FRAME off    0x000000000012ee28 vaddr 0x000000000012ee28 paddr 0x000000000012ee28 align 2**2
         filesz 0x00000000000058c4 memsz 0x00000000000058c4 flags r--
   STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4
         filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
   RELRO off    0x0000000000160660 vaddr 0x0000000000170660 paddr 0x0000000000170660 align 2**0
         filesz 0x00000000000019a0 memsz 0x00000000000019a0 flags r--

Dynamic Section:
  NEEDED               libdl.so.2
  NEEDED               librt.so.1
  NEEDED               libpthread.so.0
  NEEDED               libc.so.6
  SONAME               libgit2-a418d9d.so.1.7
  INIT                 0x00000000000161e0
  FINI                 0x000000000011636c
  INIT_ARRAY           0x0000000000170660
  INIT_ARRAYSZ         0x0000000000000008
  FINI_ARRAY           0x0000000000170668
  FINI_ARRAYSZ         0x0000000000000008
  GNU_HASH             0x00000000000001f0
  STRTAB               0x0000000000008140
  SYMTAB               0x0000000000001cd8
  STRSZ                0x000000000000572c
  SYMENT               0x0000000000000018
  PLTGOT               0x0000000000171fe8
  PLTRELSZ             0x0000000000003c48
  PLTREL               0x0000000000000007
  JMPREL               0x0000000000012598
  RELA                 0x000000000000e140
  RELASZ               0x0000000000004458
  RELAENT              0x0000000000000018
  VERNEED              0x000000000000e0d0
  VERNEEDNUM           0x0000000000000003
  VERSYM               0x000000000000d86c
  RELACOUNT            0x00000000000002c6

Version References:
  required from libdl.so.2:
    0x06969197 0x00 04 GLIBC_2.17
  required from libpthread.so.0:
    0x06969197 0x00 03 GLIBC_2.17
  required from libc.so.6:
    0x06969185 0x00 05 GLIBC_2.25
    0x06969197 0x00 02 GLIBC_2.17

Am i missing something? How could I get more info about why the shared library 'git2-a418d9d' can not be loaded?

Any help appreciated :-)

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从报告的 Repository.Init 调用和 LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary 开始,然后检查 APK 的 lib/arm64-v8a 条目以及 Android logcat 输出。将原生库声明的依赖项与 Android 的加载器要求进行比较;完成的标准是确定加载失败的原因,并记录一种可复现的解决方案。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, csharp
领域
mobile-dev
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。