请选择 进入手机版 | 继续访问电脑版

NDK abiFilters含义

[复制链接]
钟启航 发表于 2021-1-1 18:28:22 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
  NDK开发时,在build.gradle中,cmake和ndk都有abiFilters的设置。如下所示:
  1.             cmake {                cppFlags ""                abiFilters "armeabi-v7a"            }            ndk {                abiFilters "armeabi-v7a"            }
复制代码
  它们的含义有所差异。cmake设置的abiFilters会让项目编译时只生成对应abi的so, ndk 设置的abiFilters会成为对应apk的primaryCpuAbi。如果不设置这一项,系统会寻找ro.product.cpu.abilist的值,将ro.product.cpu.abilist的值的第一项(64位处理惩罚器手机下为arm64-v8a)作为应用的abi,那么寻找so目次是在lib/arm64/下寻找的。所以,如果设置了cmake的abiFilters为armeabi-v7a,务必把ndk的abiFilters也设置为armeabi-v7a,否则会报以下错误:
  1. --------- beginning of crash03-24 18:17:52.113  5739  5739 E AndroidRuntime: FATAL EXCEPTION: main03-24 18:17:52.113  5739  5739 E AndroidRuntime: Process: com.example.inlinehook, PID: 573903-24 18:17:52.113  5739  5739 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.inlinehook-ZI6gBWAJBMiKAWoKzcH-hA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.inlinehook-ZI6gBWAJBMiKAWoKzcH-hA==/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libinlinehook.so"03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at java.lang.Runtime.loadLibrary0(Runtime.java:1011)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at java.lang.System.loadLibrary(System.java:1657)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at com.example.inlinehook.MainActivity.(MainActivity.java:12)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at java.lang.Class.newInstance(Native Method)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.app.Instrumentation.newActivity(Instrumentation.java:1174)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2862)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3054)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.app.ActivityThread.-wrap11(Unknown Source:0)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.os.Handler.dispatchMessage(Handler.java:106)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.os.Looper.loop(Looper.java:164)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at android.app.ActivityThread.main(ActivityThread.java:7009)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at java.lang.reflect.Method.invoke(Native Method)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)03-24 18:17:52.113  5739  5739 E AndroidRuntime:         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)03-24 18:17:52.118   869   900 W ActivityManager:   Force finishing activity com.example.inlinehook/.MainActivity
复制代码
来源:https://blog.csdn.net/Invoker123/article/details/112055328
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


专注素材教程免费分享
全国免费热线电话

18768367769

周一至周日9:00-23:00

反馈建议

27428564@qq.com 在线QQ咨询

扫描二维码关注我们

Powered by Discuz! X3.4© 2001-2013 Comsenz Inc.( 蜀ICP备2021001884号-1 )