1,应用名和现象

运行环境: 云手机

现象: 

应用兼容性问题-abi动态库错误分析和解决_Android应用兼容性

2,分析

--------- beginning of crash
08-14 03:59:59.014 28740 28740 E AndroidRuntime: FATAL EXCEPTION: main
08-14 03:59:59.014 28740 28740 E AndroidRuntime: Process: com.ksxkq.autoclick, PID: 28740
08-14 03:59:59.014 28740 28740 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.ksxkq.autoclick-tOipfjY1awBPkGTvjsBKzQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.ksxkq.autoclick-tOipfjY1awBPkGTvjsBKzQ==/lib/arm, /data/app/com.ksxkq.autoclick-tOipfjY1awBPkGTvjsBKzQ==/base.apk!/lib/armeabi, /system/lib]]] couldn't find "libmmkv.so"
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at java.lang.System.loadLibrary(System.java:1669)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at com.tencent.mmkv.MMKV.doInitialize(MMKV.java:194)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at com.tencent.mmkv.MMKV.initialize(MMKV.java:181)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at com.tencent.mmkv.MMKV.initialize(MMKV.java:84)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at com.ksxkq.autoclick.MMKVManager.init(Unknown Source:118)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at com.ksxkq.autoclick.provider.InitializeContentProvider.onCreate(Unknown Source:104)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.app.ActivityThread.installProvider(ActivityThread.java:6438)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5985)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5900)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.app.ActivityThread.access$1100(ActivityThread.java:200)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1651)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:193)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6716)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
08-14 03:59:59.014 28740 28740 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
08-14 03:59:59.015  2190 12404 W ActivityManager:   Force finishing activity com.ksxkq.autoclick/.ui.InterstitialAdActivity
08-14 03:59:59.018 28740 28740 I Process : Sending signal. PID: 28740 SIG: 9
08-14 03:59:59.068  2190 12404 I ActivityManager: Process com.ksxkq.autoclick (pid 28740) has died: fore TOP
08-14 03:59:59.068  2190  2207 W libprocessgroup: kill(-28740, 9) failed: No such process
08-14 03:59:59.068  2190  2207 I libprocessgroup: Successfully killed process cgroup uid 10063 pid 28740 in 0ms
08-14 03:59:59.068  2128  2128 I Zygote  : Process 28740 exited due to signal (9)
 

通过日志可以看到该问题是因为加载native底层库 libmmkv.so失败导致,通过查看安装路径: 

/data/app/com.ksxkq.autoclick-tOipfjY1awBPkGTvjsBKzQ==/lib/arm # ls
libsgcore.so libutils.so
 

发现确实没有这个库,但是通过查看apk文件发现,这个apk有不同架构: 

应用兼容性问题-abi动态库错误分析和解决_java_02

 

发现arm64-v8a中有libmmkv.so, 而armeabi中没有

应用兼容性问题-abi动态库错误分析和解决_Android系统底层_03

应用兼容性问题-abi动态库错误分析和解决_Android ROM定制_04

说明默认安装,选择了了armeabi的库。

通过查看abilist,可以看到原因

# getprop | grep abi
[ro.product.cpu.abi]: [x86_64]
[ro.product.cpu.abilist]: [x86_64,x86,armeabi,armeabi-v7a,arm64-v8a]
[ro.product.cpu.abilist32]: [x86,armeabi,armeabi-v7a]
[ro.product.cpu.abilist64]: [x86_64,arm64-v8a]
[ro.vendor.product.cpu.abilist]: [x86_64,x86,armeabi,armeabi-v7a,arm64-v8a]
[ro.vendor.product.cpu.abilist32]: [x86,armeabi,armeabi-v7a]
[ro.vendor.product.cpu.abilist64]: [x86_64,arm64-v8a]

 可以看到,优先是安装了armeabi的底层库。

3, 解决

方法1, 如果有源码,就修改产品的的配置文件,调整顺序: 

# Native Bridge ABI List
NB_ABI_LIST_32_BIT := armeabi armeabi-v7a
NB_ABI_LIST_64_BIT := arm64-v8a
 

方法2: 手动安装

adb install --abi arm64-v8a 贝利自动电击器.apk

最后可以正常启动

应用兼容性问题-abi动态库错误分析和解决_Android应用兼容性_05