depends on undefined modules
问题:
1 | Users/shenjunwei/program/android-ndk-r14b/build/core/build-binary.mk:687: Android NDK: Module magicsdk_fmod depends on undefined modules: cutils |
解决方案:
Android.mk中增加APP_ALLOW_MISSING_DEPS=true
shared library text segment is not shareable
问题:
1 | /Users/shenjunwei/program/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: warning: shared library text segment is not shareable |
解决:
1 | from Android NDK r11 you can use |
has text relocations
问题:
1 | /data/app/com.wonxing.touchfa-2/lib/arm/libmagicsdk_ex.so: has text relocations |
解决:
- 方案一 This issue could be solved by checking the targetSDKVersion in the manifest file.
Using “22” and not “23” as targetSDKVersion solved it. (See below)
1 | <uses-sdk |
I also checked the build.gradle files for compile version and targetSDKversion:
1 | compileSdkVersion 22 |
- 方案二
It was caused by the ffmpeg, and it could also be solved by patching the latest ffmpeg code
1
2
3
4
5libavcodec\arm\fft_fixed_neon.S
libavcodec\arm\fft_neon.S
libavcodec\arm\fft_vfp.S
libavcodec\arm\mlpdsp_armv5te.S
libutil\arm\asm.S
I took the latest from https://github.com/FFmpeg/FFmpeg
You will also need HAVE_SECTION_DATA_REL_RO declared somewhere in your build for the macro in asm.S to use the dynamic relocations option.
- 方案三(Further informations:) Previous versions of Android would warn if asked to load a shared library with text relocations:
“libfoo.so has text relocations. This is wasting memory and prevents security hardening. Please fix.”.
Despite this, the OS will load the library anyway. Marshmallow rejects library if your app’s target SDK version is >= 23. System no longer logs this because it assumes that your app will log the dlopen(3) failure itself, and include the text from dlerror(3) which does explain the problem. Unfortunately, lots of apps seem to catch and hide the UnsatisfiedLinkError throw by System.loadLibrary in this case, often leaving no clue that the library failed to load until you try to invoke one of your native methods and the VM complains that it’s not present.
You can use the command-line scanelf tool to check for text relocations. You can find advice on the subject on the internet; for example https://wiki.gentoo.org/wiki/Hardened/Textrels_Guide is a useful guide.
And you can check if your shared lbirary has text relocations by doing this:
1 | readelf -a path/to/yourlib.so | grep TEXTREL |
If it has text relocations, it will show you something like this:
1 | 0x00000016 (TEXTREL) 0x0 |
If this is the case, you may recompile your shared library with the latest NDK version available:
1 | ndk-build -B -j 8 |
And if you check it again, the grep command will return nothing.