NDK abiFilters含义

  NDK开发时,在build.gradle中,cmake和ndk都有abiFilters的设置。如下所示:

            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,不然会报以下错误:

--------- beginning of crash
03-24 18:17:52.113  5739  5739 E AndroidRuntime: FATAL EXCEPTION: main
03-24 18:17:52.113  5739  5739 E AndroidRuntime: Process: com.example.inlinehook, PID: 5739
03-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.<clinit>(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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Invoker123

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值