feat(android): add SDK version validation and doctor command#15
Merged
Conversation
Add automatic detection and helpful error messages when project build.gradle has hardcoded SDK versions that don't match the plugin-provided SDK versions. Features: - Validate build.gradle on shell init (non-blocking warning) - New `android.sh doctor` command to diagnose SDK mismatches - Clear error messages with copy-paste fix instructions - Documentation on configuring SDK versions This improves DX when adopting the plugin by catching the common issue where Gradle tries to download SDK versions that aren't available in the immutable Nix store. Example error message: ```⚠️ WARNING: SDK version mismatch detected Your android/build.gradle has hardcoded compileSdkVersion=33 But this plugin provides Android API 35 This will cause build failures because Gradle will try to download API 33, but only API 35 is available in the Nix store. 📋 To fix, update your android/build.gradle to read from environment variables: buildscript { ext { def compileSdkEnv = System.getenv("ANDROID_COMPILE_SDK") ?: "35" compileSdkVersion = compileSdkEnv.toInteger() } } ``` Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds automatic detection and helpful error messages when a project's
build.gradlehas hardcoded SDK versions that don't match the plugin-provided SDK versions.Problem
When adopting the Android plugin, users commonly hit build failures like:
This happens because:
build.gradlehas hardcodedcompileSdkVersion = 33/nix/storeThis is confusing and frustrating for new users.
Solution
1. Automatic Validation on Shell Init
When running
devbox shell, the plugin now checks for SDK version mismatches and displays a clear warning:2. Doctor Command
Added
android.sh doctorcommand to diagnose environment and configuration issues:$ devbox run android.sh doctor 🔍 Android Environment Check ============================== ✓ ANDROID_SDK_ROOT: /nix/store/.../androidsdk/libexec/android-sdk Tools availability: ✓ adb: /nix/store/.../bin/adb ✓ emulator: /nix/store/.../bin/emulator ✓ sdkmanager: /nix/store/.../bin/sdkmanager ✓ avdmanager: /nix/store/.../bin/avdmanager Plugin-provided SDK versions: ANDROID_COMPILE_SDK: 35 ANDROID_TARGET_SDK: 35 ANDROID_BUILD_TOOLS_VERSION: 35.0.0 ANDROID_NDK_VERSION: 27.0.12077973 Project android/build.gradle detected: compileSdkVersion = 33 targetSdkVersion = 33 buildToolsVersion = "30.0.3" ⚠️ WARNING: SDK version mismatch detected [... same helpful message as above ...]3. Documentation
Added comprehensive documentation in README.md covering:
Design Principles
Testing
Tested with:
android.sh doctorcommand → displays full diagnostic infoRelated
This was discovered while debugging analytics-react-native E2E test failures where the examples had hardcoded API 33 but the plugin provided API 35.
🤖 Generated with Claude Code