4

In the gui you can go to Settings->About Phone->Firmware Version and get 2.1 (or whatever). How do I do it from command line (or for a native application that needs to do it in run time ) ?

Janusz
  • 187,060
  • 113
  • 301
  • 369
Dror Cohen
  • 6,731
  • 5
  • 29
  • 32

2 Answers2

2

The NDK doesn't run on the phone, it's just a set of tools that let you build native libraries that will run on Android devices. As such, there is no version checking.

The only hard requirement is that you use Android 1.5 or above:

The native libraries created by the Android NDK can only be used on devices running the Android 1.5 platform version or later.

However, if you want to use particular parts of the OpenGL ES APIs, you need to make sure your app is running on a certain version of the Android OS — but this is done as normal via the AndroidManifest.xml file.

See http://developer.android.com/sdk/ndk/index.html#requirements for more details.

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
  • so what is this firmware version that I'm seeing in the GUI - I assumed it's the ndk version since numbers matched ("assumptions is the mother all f##kups..."). And do you know where it comes from ? – Dror Cohen Mar 14 '10 at 15:34
  • That's the Android OS version, which you can access in Java via `android.os.Build.VERSION.RELEASE`. You shouldn't need to look at that though; the `minSdkVersion` attribute in the manifest should be enough. – Christopher Orr Mar 14 '10 at 16:43
  • Also when using OpenGL you can specify what version of OpenGL need at least: for OpenGL 1.1 for example. – Moritz Mar 14 '10 at 16:49
  • thanks for the information. How do I get the os version from my native application (at runtime) ? – Dror Cohen Mar 14 '10 at 21:50
  • 1
    As far as I'm aware, there is no such function to do so. The NDK is only for writing native libraries, not fully native Android applications. You'll always need a Java (dalvik) application to be running in order to utilise components written using the NDK, therefore any runtime version checks should be enforced via the AndroidManifest.xml file, or via Java code. – Christopher Orr Mar 14 '10 at 22:20
2

Actually, that is a good question. If I want to enable compilations on both versions, I need to know what version of NDK I'm using, because the code tree structure is different between the 2 of them. I found that there is some kind of a variable they are using inside one of their internal makefiles, but it is the same for both versions.

I hope google will add a way to distinguish between the versions in the future.

Ofer
  • 21
  • 1