Skip to content

Migrate build system to Kotlin DSL, centralize versions, and modernize source files#1171

Open
Jake-The-Human wants to merge 10 commits into
android:mainfrom
Jake-The-Human:update-build-files
Open

Migrate build system to Kotlin DSL, centralize versions, and modernize source files#1171
Jake-The-Human wants to merge 10 commits into
android:mainfrom
Jake-The-Human:update-build-files

Conversation

@Jake-The-Human

Copy link
Copy Markdown

Overview

This PR modernizes the build system across the ndk-samples repository by migrating to the Kotlin DSL and centralizing dependency management. It also includes comprehensive cleanups for C++ and Java source files to adhere to modern standards.

Key Changes

  • Build System Migration: Migrated all build.gradle files to build.gradle.kts (Kotlin DSL) across all sample modules.
  • Centralized Dependency Management: Transitioned to using a Version Catalog (libs.versions.toml) to manage dependencies and SDK versions centrally.
    • Bumped compileSdk and targetSdk to 37.
    • Bumped minSdk to 24.
    • Updated AGP, Kotlin, and Gradle wrapper versions.
  • Native Build Updates:
    • Bumped minimum CMake version to 4.1.0 in all CMakeLists.txt files.
    • Configured specific NDK and CMake versions in the Version Catalog.
  • Source Code Modernization:
    • Cleaned up and modernized C++ includes (e.g., replacing <math.h> with <cmath>, <stdlib.h> with <cstdlib>, etc.).
    • Cleaned up Java imports and modernized Java source files.
  • Housekeeping:
    • Updated README.md with new build instructions and Android Studio recommendations.
    • Removed obsolete files including fix_gradle.py and implementation_plan.artifact.md.

Testing

  • Successfully synced and built projects with the updated Gradle configs and Kotlin DSL.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request performs a major build system upgrade, updating the Android Gradle Plugin, Kotlin, Gradle, and CMake versions across all sample modules, while migrating build files to Kotlin DSL and centralizing SDK configurations in the Version Catalog. It also modernizes C++ standard library headers and cleans up deprecated Android APIs. Feedback highlights a potential crash in NativeAudio.java due to unsafe parsing of nullable audio manager properties, and an improper process termination in VulkanActivity.kt that should be replaced with standard activity lifecycle methods.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread native-audio/app/src/main/java/com/example/nativeaudio/NativeAudio.java Outdated
* Migrate all Gradle build scripts (build.gradle, settings.gradle) from Groovy to Kotlin DSL (.kts).
* Centralize dependency and plugin management using a Version Catalog (libs.versions.toml).
* Implement convention plugins in `build-logic` to encapsulate shared Android, NDK, and Kotlin configurations.
* Upgrade CMake minimum version to 4.1.0 across all modules.
* Update README.md to reflect modern build requirements and Gradle 10 readiness.
* Refactor native-midi and hello-vulkan to handle non-final resource IDs and remove deprecated APIs.
* Fix template syntax in vectorization benchmark for improved C++ standards compliance.
Removed module-specific minSdk overrides to rely on the centralized value defined in the Version Catalog and applied via convention plugins.
* Refactor CameraActivity to use lambdas for UI listeners and fix precision in slider positioning.
* Modernize NDKHelper with text blocks and remove deprecated TargetApi annotations.
* Remove unused imports across modified Java files for better code health.
* Optimized C++ includes and modernized headers across multiple modules (camera, gles, teapots, vectorization).
* Cleaned up unused and redundant Java/Kotlin imports in all sample applications.
* Standardized header guards and include patterns for better compilation performance and consistency.
* Removed deprecated annotations and unused resource references.
* Applied consistent minSdk and import formatting to teapots and native modules.
* Cleaned up remaining Java source inconsistencies in NativeAudio and NDKHelper.
@Jake-The-Human
Jake-The-Human marked this pull request as ready for review July 17, 2026 20:41
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@Sharjeel-Khan Sharjeel-Khan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning all of this up.

I think it might be a good idea to tell Android Studio that we are doing this so they are not surprised during the next QA for the NDK.

Comment thread gradle/libs.versions.toml
minSdk = "24"
ndk = "29.0.14206865"
cmake = "4.1.2"
javaTarget = "17"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from compileSdk and targetSdk, do we want to make everything minimum? I only mention this because Dan used to say we should make sure the minimum specs we mention works with everything.

The ndk will be bumped to NDK r30 after it releases but the LTS is 27.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i removed the ndk version line and did a clean build and android studio install 28.2.13676358 on its own. so im not sure what we should do.

Comment thread hello-vulkan/app/build.gradle.kts
Comment thread gradle.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants