Search code examples
android-ndkkindle-firegradle-experimental

Missing c standard library symbols when loading NDK library on Kindle Fire


My Android app has an NDK library. When running it on a Kindle Fire HD with Fire OS 4.5.5, the app fails to load the NDK library because some C standard library symbols are unresolved i.e. they appear to be entirely missing:

  • rand()
  • srand()
  • signal()

This problem does not happen on my Nexus 5 with stock Android 6.

Does anyone know why these symbols are missing entirely, and if there an official list somewhere of such missing symbols?

Are there any other "major" Android forks out there with such non-conventional C standard libraries?

UPDATE: I'm compiling the app and the NDK library using Android Studio 1.5.1 and the Gradle experimental plugin 0.4.0.

compileOptions.with {
    sourceCompatibility=JavaVersion.VERSION_1_7
    targetCompatibility=JavaVersion.VERSION_1_7
}

android {
    compileSdkVersion = 23
    buildToolsVersion = "23.0.2"

    defaultConfig.with {
        applicationId = "net.pol_online.hyper"
        minSdkVersion.apiLevel = 18  // Android 4.3 Jelly Bean
        targetSdkVersion.apiLevel = 23  // Android 6.0 Marshmallow
    }
}

UPDATE: The solution was to set this in the Gradle config as it turns out that minSdkVersion.apiLevel does not affect the NDK:

android.ndk {
   platformVersion = "18"
}

Solution

  • Are you sure that you've built your NDK library targeting the right native API level? If you've built it targeting android-21 or newer and running on older android versions - especially these functions will fail. See https://stackoverflow.com/a/27338365/3115956 and https://stackoverflow.com/a/27093163/3115956 for more details.