Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAB] Feature: Support AAB And extractNativeLibs=false #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shiqos
Copy link

@shiqos shiqos commented Sep 5, 2024

项目未配置 useLegacyPackaging=true 时,
使用AAB安装, 或最低版本为Android M以上的APK
Native库不会从APK中解压, 参考:
https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs google/bundletool#39

此时xCrash通过 ctx.getApplicationInfo().nativeLibraryDir 获取的目录内容是空的 因此会出现加载xcrash_dumper失败

而通过 PathClassloader.findLibrary(libName) 获取的路径是虚拟路径, 不是真实存在的 因此直接执行也会失败

此时我们参考 Crashpad 的逻辑, 使用linker加载
参考:
https://github.com/chromium/crashpad/blob/main/client/crashpad_client_linux.cc#L114

为了避免大的改动, 默认仅在加载虚拟路径时使用linker, 实际上在所有场景都可以直接通过linker加载

支持外部自定义配置

.setNativeLibPath()
.setLoadNativeWithLinker()

如果外部没有配置,内部会自动查找
参考: AbiPathProvider.java 逻辑

项目未配置 `useLegacyPackaging=true` 时,
使用AAB安装, 或最低版本为Android M以上的APK
Native库不会从APK中解压, 参考:
https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs
google/bundletool#39

此时xCrash通过 `ctx.getApplicationInfo().nativeLibraryDir` 获取的目录内容是空的
因此会出现加载xcrash_dumper失败

而通过 PathClassloader.findLibrary(libName) 获取的路径是虚拟路径, 不是真实存在的
因此直接执行也会失败

此时我们参考 Crashpad 的逻辑, 使用linker加载
参考:
https://github.com/chromium/crashpad/blob/main/client/crashpad_client_linux.cc#L114

为了避免大的改动, 默认仅在加载虚拟路径时使用linker, 实际上在所有场景都可以直接通过linker加载

支持外部自定义配置
```
.setNativeLibPath()
.setLoadNativeWithLinker()
```

如果外部没有配置,内部会自动查找
参考: AbiPathProvider.java 逻辑
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant