You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have updated from NDK r11c to r12 and there are some missing references when loading my shared library:
(at least):
00000000 DF UND 00000000 LIBC_N __aeabi_memclr4
00000000 DF UND 00000000 LIBC_N __aeabi_memmove
00000000 DF UND 00000000 LIBC_N __aeabi_memclr8
00000000 DF UND 00000000 LIBC_N __aeabi_memcpy
00000000 DF UND 00000000 LIBC_N __aeabi_memcpy4
00000000 DF UND 00000000 LIBC_N __aeabi_memclr
00000000 DF UND 00000000 LIBC_N __aeabi_memset
00000000 DF UND 00000000 LIBC_N __aeabi_atexit
With (compileSdkVersion=24, targetSdkVersion=23), it runs.
But it requires to install both SDK Platform 23 & 24. Why, since I specified "compileSdkVersion=24", I would expect to download and need only the package "Android N (API 24) SDK Plaform" ?
I should be able to bump "targetSdkVersion" to 24, but it fails to run because of undefined reference (at least "__aeabi_memclr4"). Doesn't seem to be an API thing, but more low level library issue ?
Signification of {min,max,target, compile}SdkVersion is quite blur ... (for years)
Also happens to us, but only for armeabi-v7a target on some devices (HTC One M8, Android 6.0; SGS5; Android 6.0). It is weird that it does not happen on SGS4, Android 5.0.1 nor on Huawei P8Lite, Android 5.0.1. It also does not happen on arm64-v8a on SGS6, Android 6.0.
Confirmed that setting target=android-23 works. Are there any known workarounds to make it work when targeting android-24? We had similar issue when upgrading from android-19 to android-21 in order to be able to use GLES3 on compatible devices - some functions used to be defined in headers in android-19 platform and were moved to lib in android-21 - therefore we needed to implement those functions in our code.
I think there is confusion between targetSdkVersion and LOCAL_SDK_VERSION
NDK interpretation of LOCAL_SDK_VERSION is minimum SDK version - which means that it is not guaranteed to work on devices with sdk < LOCAL_SDK_VERSION.
I am not sure how targetSdkVersion gets propagated to LOCAL_SDK_VERSION - do you use gradle to build native libraries?
(You are getting this error because if LOCAL_SDK_VERSION is set to 24 these symbols get LIBC_N version. These symbols were mistakenly versioned as LIBC_PRIVATE instead of LIBC in android-23 which was fixed in 24, hence the symbol version mismatch if you try to run load the library linked against libc.so from android-24 on android-23)
@DoDoENT
I believe this is used implicitly, when application uses "memset", or maybe when initializing some array. You linked (statically) with the libc of the targeted sdk.
Then, calling objdump -T on my shared library displays:
An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion.
This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).
@1bsyl, I was referring to APP_PLATFORM NDK parameter - it has to be set to android-23 or lower. Nevertheless, in your build.gradle you can target API level 24 (it is used only for Java code).
@1bsyl indeed, unless you need to use some NDK features available only in later API levels (like for example GLES3 on compatible devices, while falling back to GLES2 on older devices - in order to access GLES3 headers, you need APP_PLATFORM=android-21 or later, which produces binary which is not so compatible with KitKat and earlier Android versions).
And, bumping targetSdkVersion to 24 in build.gradle and AndroidManifest.xml, can it have some bad side effect ? (while keeping a lower APP_PLATFORM for the ndk side).
@1bsyl from our experience at MicroBlink we recommend having compileSdkVersion always set to latest stable API level (currently this is 24), targetSdkVersion set to latest API level with which you have extensively tested your app (for us this is still 23, as we cannot test with 24 because Android N is still not released - bugs and failures on preview versions can be attributed to both bugs in your app as well as bugs in platform itself - this is why we usually wait for Google to release official build of new Android version and then we test on it) and minSdkVersion set to minimum API level your app supports (for us this is still 10 :-( ).
One example where you may put your targetSdkVersion to 21, while using compileSdkVersion on 24 would be case when you have not implemented Android M permission model in your app. Similarly, if you have not prepared your app to work in multi-window environment introduced in Android N (will it be called Nutella?) you should not set targetSdkVersion to 24 (setting it so would mean that you have tested your app in multi window environment and this feature will be enabled for your app on devices running Android N).
On NDK side, you should set APP_PLATFORM to same as minSdkVersion in build.grade to be absolutely sure your app will work correctly. However, if you need NDK features that were introduced in later API levels, you should set APP_PLATFORM to minimum API level which gives a feature you need and then test intensively on lower API levels to ensure everything works (this may require some weird hacks to ensure binary built with APP_PLATFORM=android-23 to work on Gingerbread :-P ).
Is platformVersion the thing it uses? I'm not a gradle user so I don't know how to configure it, but whatever gradle is using for your NDK API level needs to match your minSdkVersion.
with #include <GLES3/gl3.h> used for including the OpenGL ES header.
I now want to use some 3.1 and 3.2 functions on devices that support them so have modified ANDROID_PLATFORM to DANDROID_PLATFORM=android-24 and my header include to #include <GLES3/gl32.h>. This (correctly) leads to my Android 5.0 (API 21) test device failing to load my native library with the error:
dlopen failed: cannot locate symbol [insert new 3.1/3.2 function name here]
I have no problem with finding whether these newer functions exist at runtime using eglGetProcAddress, however after reading your comment on unified headers (specifically the second paragraph about it being made easier) is this still the recommended way or is there an easier one?
eglGetProcAddress is still the recommended way. danalbert was just saying that unified headers mean that you'll have the <GLES3/gl3.h> header available even if you're targeting an API level that predates that header.
If I set the NDK API level to 21, it failed with 718
undefined reference to 'globfree'
which was fixed in r17b. Now this is a dead end to me.
it's a mistake to think that globfree() was "fixed" in r17b. glob() and globfree() were added in API 28. you cannot use them in an app that needs to run on earlier OS versions.
(a workaround is to copy the source from bionic in AOSP into your app's source.)
I know this is an old and closed issue for an older version of the NDK, and I apologize for posting here, but I'm going through the exact same issue (java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memclr8" referenced by "libtwampc.so"... on devices running androud 4.x), and I'm fairly confident that I got the right API level (but I could be wrong).
I'm compiling using a standalone toolchain, and my environment setup currently looks like this:
(I've added the defines for ANDROID_PLATFORM, __ANDROID_API__, and APP_PLATFORM after going through a few similar issues, but they did absolutely nothing for me)
As far as I understand, I'm compiling my binary for anything at API level 16 or above, and yet, it consistently crashes with devices running android 4.x (e.g. 4.3, 4.4.2, all running under armeabi-v7a). Am I overlooking something? Am I doing something stupid? Or is this really an issue?
Sorry for forgetting such a crucial detail. Those are the flags I'm using to build libtwampc.so and another library used by libtwampc as a dependency. I can load the dependency library just fine, even in the devices where trying to load libtwampc.so fails.
Activity
dimitry- commentedon Jun 19, 2016
Looks like you are targeting 24 but running on previous version of android.
1bsyl commentedon Jun 19, 2016
Yes, I was about to write the solution, I am using targetSdkVersion=24 on a lower device.
1bsyl commentedon Jun 19, 2016
I reopen to have more feedback:
With (compileSdkVersion=24, targetSdkVersion=23), it runs.
But it requires to install both SDK Platform 23 & 24. Why, since I specified "compileSdkVersion=24", I would expect to download and need only the package "Android N (API 24) SDK Plaform" ?
According to:
http://stackoverflow.com/questions/26694108/what-is-the-difference-between-compilesdkversion-and-targetsdkversion
I should be able to bump "targetSdkVersion" to 24, but it fails to run because of undefined reference (at least "__aeabi_memclr4"). Doesn't seem to be an API thing, but more low level library issue ?
Signification of {min,max,target, compile}SdkVersion is quite blur ... (for years)
DoDoENT commentedon Jun 29, 2016
Also happens to us, but only for armeabi-v7a target on some devices (HTC One M8, Android 6.0; SGS5; Android 6.0). It is weird that it does not happen on SGS4, Android 5.0.1 nor on Huawei P8Lite, Android 5.0.1. It also does not happen on arm64-v8a on SGS6, Android 6.0.
DoDoENT commentedon Jun 29, 2016
Confirmed that setting
target=android-23works. Are there any known workarounds to make it work when targetingandroid-24? We had similar issue when upgrading fromandroid-19toandroid-21in order to be able to use GLES3 on compatible devices - some functions used to be defined in headers inandroid-19platform and were moved to lib inandroid-21- therefore we needed to implement those functions in our code.DoDoENT commentedon Jun 29, 2016
Where are these functions defined?
finds nothing.
dimitry- commentedon Jun 29, 2016
I think there is confusion between targetSdkVersion and LOCAL_SDK_VERSION
NDK interpretation of LOCAL_SDK_VERSION is minimum SDK version - which means that it is not guaranteed to work on devices with sdk < LOCAL_SDK_VERSION.
I am not sure how targetSdkVersion gets propagated to LOCAL_SDK_VERSION - do you use gradle to build native libraries?
(You are getting this error because if LOCAL_SDK_VERSION is set to 24 these symbols get LIBC_N version. These symbols were mistakenly versioned as LIBC_PRIVATE instead of LIBC in android-23 which was fixed in 24, hence the symbol version mismatch if you try to run load the library linked against libc.so from android-24 on android-23)
1bsyl commentedon Jun 29, 2016
@DoDoENT
I believe this is used implicitly, when application uses "memset", or maybe when initializing some array. You linked (statically) with the libc of the targeted sdk.
Then, calling
objdump -Ton my shared library displays:targetSdkVersion 24:
00000000 DF *UND* 00000000 LIBC_N __aeabi_memclr4targetSdkVersion 23:
00000000 DF *UND* 00000000 __aeabi_memclr4I use gradle, but with some ndk commands so that it seems equivalent to calling ndk-build
(with command line option
APP_PLATFORM=android-24)My build.gradle contains
targetSdkVersion 23 (or 24, which leads to the issue)
compileSdkVersion 24
AndroidManifest.xml, my minSdkVersion is 10.
According to : https://developer.android.com/guide/topics/manifest/uses-sdk-element.htm
android:targetSdkVersion
An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion.
This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).
DoDoENT commentedon Jun 29, 2016
@1bsyl, I was referring to APP_PLATFORM NDK parameter - it has to be set to
android-23or lower. Nevertheless, in your build.gradle you can target API level 24 (it is used only for Java code).1bsyl commentedon Jun 29, 2016
In fact, the safest, is to set APP_PLATFORM to the minSdkLevel ?
And to keep other "targetSdkVersion" and "compileSdkVersion" to 24.
DoDoENT commentedon Jun 29, 2016
@1bsyl indeed, unless you need to use some NDK features available only in later API levels (like for example GLES3 on compatible devices, while falling back to GLES2 on older devices - in order to access GLES3 headers, you need APP_PLATFORM=android-21 or later, which produces binary which is not so compatible with KitKat and earlier Android versions).
1bsyl commentedon Jun 29, 2016
@DoDoENT
Ok! your example totally makes sense.
And, bumping targetSdkVersion to 24 in build.gradle and AndroidManifest.xml, can it have some bad side effect ? (while keeping a lower APP_PLATFORM for the ndk side).
DoDoENT commentedon Jun 29, 2016
@1bsyl from our experience at MicroBlink we recommend having compileSdkVersion always set to latest stable API level (currently this is 24), targetSdkVersion set to latest API level with which you have extensively tested your app (for us this is still 23, as we cannot test with 24 because Android N is still not released - bugs and failures on preview versions can be attributed to both bugs in your app as well as bugs in platform itself - this is why we usually wait for Google to release official build of new Android version and then we test on it) and minSdkVersion set to minimum API level your app supports (for us this is still 10 :-( ).
One example where you may put your targetSdkVersion to 21, while using compileSdkVersion on 24 would be case when you have not implemented Android M permission model in your app. Similarly, if you have not prepared your app to work in multi-window environment introduced in Android N (will it be called Nutella?) you should not set targetSdkVersion to 24 (setting it so would mean that you have tested your app in multi window environment and this feature will be enabled for your app on devices running Android N).
On NDK side, you should set APP_PLATFORM to same as minSdkVersion in build.grade to be absolutely sure your app will work correctly. However, if you need NDK features that were introduced in later API levels, you should set APP_PLATFORM to minimum API level which gives a feature you need and then test intensively on lower API levels to ensure everything works (this may require some weird hacks to ensure binary built with APP_PLATFORM=android-23 to work on Gingerbread :-P ).
23 remaining items
ajunkala commentedon Oct 6, 2017
Found the solution. You can set the NDK target version with
android.ndk {
platformVersion = "19"
}
DanAlbert commentedon Oct 6, 2017
Is platformVersion the thing it uses? I'm not a gradle user so I don't know how to configure it, but whatever gradle is using for your NDK API level needs to match your minSdkVersion.
ajunkala commentedon Oct 6, 2017
That seems to be the case. Like I noted, I can repro the issue even w/ an emulator. I just added it and the issue seems to be resolved now.
Rajveer86 commentedon Mar 23, 2018
@DanAlbert Sorry to bring up an old issue, however I am experiencing exactly what you described here (relating to this).
I have an OpenGL ES 3.0 project which supports devices on KitKat (API 19) and have the following configuration:
with
#include <GLES3/gl3.h>used for including the OpenGL ES header.I now want to use some 3.1 and 3.2 functions on devices that support them so have modified
ANDROID_PLATFORMtoDANDROID_PLATFORM=android-24and my header include to#include <GLES3/gl32.h>. This (correctly) leads to my Android 5.0 (API 21) test device failing to load my native library with the error:dlopen failed: cannot locate symbol [insert new 3.1/3.2 function name here]I have no problem with finding whether these newer functions exist at runtime using
eglGetProcAddress, however after reading your comment on unified headers (specifically the second paragraph about it being made easier) is this still the recommended way or is there an easier one?enh commentedon Mar 23, 2018
eglGetProcAddressis still the recommended way. danalbert was just saying that unified headers mean that you'll have the<GLES3/gl3.h>header available even if you're targeting an API level that predates that header.Rajveer86 commentedon Mar 23, 2018
I see, that makes perfect sense. Thank you for the quick reply, I'll go ahead with that route then :)
fix: crash on Android 6.0 on Moto G3
neevek commentedon May 20, 2019
Sorry to bring this up again, but how do I resolve the issue if I have to target 28 and support devices starting from 21? I am using NDK r19c.
DanAlbert commentedon May 20, 2019
Stop doing that. Your NDK API level is your
minSdkVersion.neevek commentedon May 20, 2019
If I set the NDK API level to 21, it failed with 718
which was fixed in r17b. Now this is a dead end to me.
enh commentedon May 20, 2019
it's a mistake to think that globfree() was "fixed" in r17b. glob() and globfree() were added in API 28. you cannot use them in an app that needs to run on earlier OS versions.
(a workaround is to copy the source from bionic in AOSP into your app's source.)
Yaakushi commentedon Feb 11, 2020
I know this is an old and closed issue for an older version of the NDK, and I apologize for posting here, but I'm going through the exact same issue (
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memclr8" referenced by "libtwampc.so"...on devices running androud 4.x), and I'm fairly confident that I got the right API level (but I could be wrong).I'm compiling using a standalone toolchain, and my environment setup currently looks like this:
And my CPPFLAGS looks like this:
(I've added the defines for
ANDROID_PLATFORM,__ANDROID_API__, andAPP_PLATFORMafter going through a few similar issues, but they did absolutely nothing for me)As far as I understand, I'm compiling my binary for anything at API level 16 or above, and yet, it consistently crashes with devices running android 4.x (e.g. 4.3, 4.4.2, all running under armeabi-v7a). Am I overlooking something? Am I doing something stupid? Or is this really an issue?
DanAlbert commentedon Feb 11, 2020
Are those flags what you're using to build libtwampc.so? Or is that a prebuilt and it's just a dependency of what you're building?
Yaakushi commentedon Feb 12, 2020
Sorry for forgetting such a crucial detail. Those are the flags I'm using to build libtwampc.so and another library used by libtwampc as a dependency. I can load the dependency library just fine, even in the devices where trying to load libtwampc.so fails.
DanAlbert commentedon Feb 12, 2020
Could you file a new bug with the
readelf -sW $LIBRARY | grep __aeabi_memclr8output for each of your libraries?