Skip to content

Build Changes

Andy Crampton edited this page Sep 9, 2025 · 2 revisions

Build Changes

Several significant changes were required to modernize the project from the original kikitte/GDAL4Android fork and ensure a successful build on modern hardware and toolchains.

1. General Android Project Updates

The Android project structure was modernized to align with current standards:

  • Gradle Wrapper: Upgraded to a recent version.
  • Kotlin DSL: The build.gradle files were converted to build.gradle.kts, the modern standard for Gradle build scripts.
  • Java Version: The project now targets Java 17.
  • Android SDK: The compileSdk was updated to 35.
  • IDE Files: .idea and .iml files were updated for a more recent Android Studio version.

2. Build Configuration

  • 16kb Page Size is Now Default: The original build script had an option for different page sizes. Now that Google is requiring 16kb page sizes, the 16kb page size is now the default and only option.
  • NDK Version 27: The project was updated to use NDK version 27.x. This is crucial for compatibility, as it matches the NDK version used by the Mapbox SDK, preventing potential runtime conflicts with native libraries.

3. Core build_cpp.sh Script Updates

The most significant changes were made to the C++ build script to enable cross-compilation on Apple Silicon (aarch64) hosts and to fix linking issues. Details can be found on the Build Script Overview page.

  • Host Architecture Resilience: The script now automatically detects the host machine's architecture (e.g., aarch64-apple-darwin for Apple Silicon, x86_64-linux-gnu for Linux) and sets the correct HOST variable for build tools like configure. This makes the script runnable on different developer machines without manual changes.
  • Shared Libraries (.so): The build process was changed to produce shared libraries (.so) instead of static archives (.a). While static linking is often preferred, it proved difficult to get the final GDAL library to correctly link all of its static dependencies. Building and linking shared libraries resolved these complex linker errors.
  • SQLite Amalgamation: The build process for SQLite was switched from using the autoconf script to using the amalgamation. The amalgamation is a single, large C source file containing the entire SQLite library. This was done because the autoconf script is designed to inspect the host system and often fails when cross-compiling for a different target like Android. The amalgamation simplifies the build process immensely by removing the need for a complex configuration step.
  • Added libpng Dependency: The PNG library was added as a required dependency. This is because the RasterReader.kt class in the app uses a pngData helper method to serve map tiles. This method internally uses GDAL's PNG driver to translate the raw raster data into a standard PNG image format that Mapbox can render. Without libpng compiled into GDAL, the PNG driver is unavailable, and the app cannot generate tiles.

Clone this wiki locally