Can I still compile for android-9 with the latest NDK r16?

259 views
Skip to first unread message

Andreas Falkenhahn

unread,
Dec 3, 2017, 1:45:02 PM12/3/17
to andro...@googlegroups.com
I've seen that Android NDK r16 doesn't have an "android-9" subdirectory
inside the "platforms" directory any longer. Instead, the oldest platform
available in the "platforms" directory is "android-14" now.

This makes me wonder whether it is still possible to target android-9
with the current NDK? Note that I'm not using Android Studio but I build
from the command line. My build.gradle file starts like this:

android {
compileSdkVersion 27
buildToolsVersion '27.0.1'
defaultConfig {
applicationId 'com.foo.bar'
minSdkVersion 9
targetSdkVersion 9
versionCode 10
versionName "1.0"
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-9',
'-DANDROID_TOOLCHAIN=clang'
}
}
}

As you can see I'm setting ANDROID_PLATFORM to "android-9" but I'm
not sure if this has any effect at all. I can compile the apk just
fine but I'm not sure if this is really still working on android-9
because there is no android-9 subdirectory in "platforms" at all...
so does this mean that the minimum version that the NDK r16 can
target is android-14 or can I still target android-9 with the NDK r16?

--
Best regards,
Andreas Falkenhahn mailto:and...@falkenhahn.com

Alex Cohn

unread,
Dec 4, 2017, 5:06:58 AM12/4/17
to android-ndk
The short answer is "NO". NDK r16 drops support for android-9, android-12, and android-13.

You can download an archive of NDK r15 to target android-9 till 13, or r10 that supports platforms from android-3 till 21.
The differences are not only extra APIs (like OpenMAX) or more functions in libc (like pread64), but also amy involve subtle compiler and linker flags, so I would not recommend to use the new toolchains for platforms where they were not tested.

Unfortunately, given the variety of Android devices, there are enough platform bugs and incompatibilities even if you use the standard tools, and older devices often have their very special quirks. I believe that (except for MIUI) the level of compliance of modern ROMs is better than it was 7 years ago.

BR,
Alex

Alex Cohn

unread,
Dec 4, 2017, 5:14:36 AM12/4/17
to android-ndk
Correction: you need r14; in r15, support for android-9 was discontinued (see https://stackoverflow.com/a/45696453/192373), even though platform-9 directory was still shipped with r15.

Alex

Andreas Falkenhahn

unread,
Dec 8, 2017, 3:34:18 PM12/8/17
to Alex Cohn, andro...@googlegroups.com
On 04.12.2017 at 11:06 Alex Cohn wrote:

> The short answer is "NO". NDK r16 drops support for android-9, android-12, and android-13.


> You can download an archive of NDK r15 to target android-9 till 13,
> or r10 that supports platforms from android-3 till 21.
> The differences are not only extra APIs (like OpenMAX) or more
> functions in libc (like pread64), but also amy involve subtle
> compiler and linker flags, so I would not recommend to use the new
> toolchains for platforms where they were not tested.


> Unfortunately, given the variety of Android devices, there are
> enough platform bugs and incompatibilities even if you use the
> standard tools, and older devices often have their very special
> quirks. I believe that (except for MIUI) the level of compliance of
> modern ROMs is better than it was 7 years ago.

Thanks for the answer!

This makes me wonder of course why there isn't an error message when
trying to build an NDK project with the following build.gradle:

android {
compileSdkVersion 27
buildToolsVersion '27.0.1'
defaultConfig {
applicationId 'com.foo.bar'
minSdkVersion 9
targetSdkVersion 9
versionCode 10
versionName "1.0"
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-9',
'-DANDROID_TOOLCHAIN=clang'
}
}
}

This compiles just fine although the resulting APK probably won't
work on Gingerbread any longer. I think Gradle should throw an error
here and tell me that I can't build for android-9 with the current
NDK any more. But it doesn't say anything. Instead it just builds
the APK without any error messages whatsoever .... and I have no
idea what the APKs minimum API will be now that android-9 is no
longer available. Had I not noticed by accident that android-9 is
no longer part of the latest NDK, I wouldn't have noticed anything...
very bad!

Dan Albert

unread,
Dec 8, 2017, 3:40:23 PM12/8/17
to android-ndk, Jomo Fisher, Raymond Chiu, Alex Cohn
I think Gradle should throw an error
here and tell me that I can't build for android-9 with the current
NDK any more. But it doesn't say anything. Instead it just builds
the APK without any error messages whatsoever

ndk-build emits a warning letting you know that the NDK API level is being pulled up to 14. Looks like cmake doesn't, but I can fix that for r17 easy enough.

Even so, I don't think gradle will expose any of that to you (even if it does, it will get buried in a ton of other log output). +jomof +chiur


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/295466617.20171208212845%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.

Jomo Fisher

unread,
Dec 8, 2017, 4:00:47 PM12/8/17
to Dan Albert, android-ndk, Raymond Chiu, Alex Cohn
Yeah, we should at least warrn. I opened https://buganizer.corp.google.com/issues/70397271 to track it

Dan Albert

unread,
Dec 8, 2017, 5:42:18 PM12/8/17
to Jomo Fisher, android-ndk, Raymond Chiu, Alex Cohn
Reply all
Reply to author
Forward
0 new messages