系统App启动异常之 java.lang.UnsatisfiedLinkError: dlopen failed: library “libopencv_java3.so“ not found

项目场景:

作为系统App启动异常之
java.lang.UnsatisfiedLinkError: dlopen failed: library “libopencv_java3.so” not found


问题描述:

将apk 放到system/app下作为启动App,启动时异常报错加载不到第三方库相关的.so文件

捕捉异常日志分析

2021-03-21 20:06:30
SUPPORTED_64_BIT_ABIS=[Ljava.lang.String;@3fd2815
versionCode=23
BOARD=msm8909
BOOTLOADER=unknown
TYPE=userdebug
ID=LMY47V
TIME=1614138391000
BRAND=qcom
TAG=Build
SERIAL=543e9bdb
HARDWARE=qcom
SUPPORTED_ABIS=[Ljava.lang.String;@2a3ea72a
CPU_ABI=armeabi-v7a
RADIO=unknown
IS_DEBUGGABLE=true
MANUFACTURER=unknown
SUPPORTED_32_BIT_ABIS=[Ljava.lang.String;@3050bdcc
TAGS=release-key
CPU_ABI2=armeabi
UNKNOWN=unknown
USER=ppdy
FINGERPRINT=qcom/msm8909/msm8909:5.1.1/LMY47V/ppdy02241145:userdebug/release-key
HOST=ppdy-HP-EliteBook-8570w
PRODUCT=msm8909
versionName=v2.0.3
DISPLAY=XY8901P1_V0.2
MODEL=msm8909
DEVICE=msm8909
java.lang.UnsatisfiedLinkError: dlopen failed: library "libopencv_java3.so" not found
	at java.lang.Runtime.loadLibrary(Runtime.java:371)
	at java.lang.System.loadLibrary(System.java:988)
	at com.ppdy.news7001.storage.doImage.doImageJni.<clinit>(doImageJni.java:17)
	at com.ppdy.news7001.storage.doImage.doImageRepositoryImpl.<init>(doImageRepositoryImpl.java:23)
	at com.zddx.mvp.presenter.NewTestPresenter.<init>(NewTestPresenter.java:181)
	at com.zddx.di.module.NewTestModule.provideNewTestPresenter(NewTestModule.java:39)
	at com.zddx.di.module.NewTestModule_ProvideNewTestPresenterFactory.provideNewTestPresenter(NewTestModule_ProvideNewTestPresenterFactory.java:41)
	at com.zddx.di.component.DaggerNewTestComponent.getNewTestPresenter(DaggerNewTestComponent.java:33)
	at com.zddx.di.component.DaggerNewTestComponent.injectNewTestFragment(DaggerNewTestComponent.java:40)
	at com.zddx.di.component.DaggerNewTestComponent.inject(DaggerNewTestComponent.java:37)
	at com.zddx.mvp.fragments.NewTestFragment.initData(NewTestFragment.java:732)
	at com.zddx.mvp.fragments.NewTestFragment.onFragmentFirstVisible(NewTestFragment.java:204)
	at com.zddx.mvp.fragments.ViewPagerBaseFragment.onViewCreated(ViewPagerBaseFragment.java:113)
	at com.zddx.mvp.fragments.NewTestFragment.onViewCreated(NewTestFragment.java:175)

重点:

java.lang.UnsatisfiedLinkError: dlopen failed: library "libopencv_java3.so" not found
    at java.lang.Runtime.loadLibrary(Runtime.java:371)
    at java.lang.System.loadLibrary(System.java:988)

猜想:

将apk 放到system/app下导致的加载不到第三方库相关的.so文件


验证:

1. 解压 news7001.apk
apk文件解压后 lib 文件夹下文件列表
共 12 个 .so文件

2. 查看 /system/app/news7001下的lib文件夹中.so文件详情
/system/app/news7001/lib/arm文件夹下文件列表
共 9 个 .so文件

**

对比发现 “libopencv_java3.so” 确实未被加载

**


解决方案:

将 apk 的 .so文件复制到 /system/lib 中

步骤:

1. root, 获取 root 权限

E:\PPDY\git-ppdyns-android20200927\git-ppdyns-android>adb root
restarting adbd as root

2. remount, 重新挂载 system 分区

E:\PPDY\git-ppdyns-android20200927\git-ppdyns-android>adb remount
remount succeeded

3. push, 推送(复制).so文件到 /system/lib 文件夹下

E:\PPDY\git-ppdyns-android20200927\git-ppdyns-android>adb push C:\Users\PPDY\Desktop\so\libopencv_java3.so /system/lib
C:\Users\PPDY\Desktop\so\libopencv_java3.so: 1 file pushed, 0 skipped. 3.6 MB/s (10969196 bytes in 2.878s)

4. reboot, 重启

E:\PPDY\git-ppdyns-android20200927\git-ppdyns-android>adb reboot

参考文章:

<<将第三方apk变成系统apk>> https://blog.51cto.com/670176656/1608687

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值