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

compat android 5.x arm64 native lib path too long #39

Conversation

Xiaojuanmao
Copy link

问题描述:

  • 安卓版本:5.x
  • Cpu型号:arm64

加载绝对路径超过 128 字符的native库会报如下异常

E/org.hmwebrtc.Logging(11605): NativeLibrary: java.lang.UnsatisfiedLinkError: dlopen failed: library name "/data/data/com.smile.gifmaker/app_qigsaw/9.0.10.99999_8d656209f28c/gamecenterplugin/1.0@1/nativeLib/arm64-v8a/libhaima_rtc_so.so" too long

复现步骤:

  1. 将项目中 native 测试模块中, hello-jni.so 名字改长一些,例如 helloooooooooooooooooooooooooo-jni.so,让整个路径超过 128 个字符,例如 /data/user/0/com.iqiyi.qigsaw.sample/app_qigsaw/1.0.0_ae5f1c9/native/1.0@1/nativeLib/arm64-v8a/libhelloooooooooooooooooooooooooo-jni.so
  2. 运行demo并加载 native 插件,会抛出 UnsatisfiedLinkError

解决方案:

  1. 在返回 nativeLibPath 之前检测是否要进行路径映射
  2. 满足条件 (5.x) && (64位) && (so文件绝对路径长度 >= 128)才进行路径映射
  3. 通过 Os.symlink 将长路径映射到 common_so 目录下,以缩短路径

@Xiaojuanmao Xiaojuanmao force-pushed the compat_android_5.x_arm64_native_path_too_long branch from ae5f1c9 to f6a642e Compare January 15, 2021 14:44
@ziyang0116 ziyang0116 merged commit 08ceda5 into iqiyi:dev Jan 16, 2021
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.

2 participants