Skip to content

Fix #63: plugin nativephp/mobile-camera mins sdk#70

Closed
shanerbaner82 wants to merge 1 commit intomainfrom
fix/issue-63-plugin-nativephpmobile-camera-mins-sdk-1774710189
Closed

Fix #63: plugin nativephp/mobile-camera mins sdk#70
shanerbaner82 wants to merge 1 commit intomainfrom
fix/issue-63-plugin-nativephpmobile-camera-mins-sdk-1774710189

Conversation

@shanerbaner82
Copy link
Copy Markdown
Contributor

Closes #63

Summary

Now I have a complete picture. Here's the analysis:


Root Cause:

There are two separate but related problems:

  1. The mobile-camera plugin's nativephp.json manifest incorrectly declares android.min_version: 33. The Kotlin code is fully guarded with Build.VERSION.SDK_INT runtime checks — API 33 was never actually required. This is the primary bug (to be fixed in the mobile-camera repo via Lower Android min SDK requirement from 33 to 26 mobile-camera#5).

  2. A secondary inconsistency in mobile-air itself: The config default for min_sdk in config/nativephp.php:172 is 33, but the validation logic in RunsAndroid.php:75 and PackageCommand.php:143 reads from config with a fallback default of 26. This means when users set NATIVEPHP_ANDROID_MIN_SDK=33 (as the reporter tried), it has no effect on bypassing the validation — the plugin's declared min_version: 33 matches the SDK, so it shouldn't block. But the actual effective min SDK used during build (PreparesBuild.php:797) also defaults to 33, meaning the mismatch report the user saw came from their app's .env having NATIVEPHP_ANDROID_MIN_SDK unset while the config defaulted to 26 in the validation path but 33 in the build path.

Files to Change:

  • nativephp/mobile-cameranativephp.json manifest: lower android.min_version from 33 to 26 (separate repo, tracked in Lower Android min SDK requirement from 33 to 26 mobile-camera#5)
  • src/Traits/PreparesBuild.php:797 — The fallback default for min_sdk is 33; this should be 26 to match the NativePHP floor and be consistent with RunsAndroid.php and PackageCommand.php

Proposed Fix:

  1. In mobile-camera (Lower Android min SDK requirement from 33 to 26 mobile-camera#5): Change android.min_version in the plugin manifest from 3326, since the Kotlin code already uses Build.VERSION.SDK_INT guards for all API-level-specific calls.

  2. In mobile-air (PreparesBuild.php:797): Change the fallback default from 33 to 26:

    // Before
    $minSdk = (int) config('nativephp.android.min_sdk', 33);
    // After
    $minSdk = (int) config('nativephp.android.min_sdk', 26);

    This makes the build-time default consistent with the validation defaults in RunsAndroid.php and PackageCommand.php, which both use 26.

Risks:

  • Low risk: The PreparesBuild.php default change only affects users who have not set NATIVEPHP_ANDROID_MIN_SDK in their .env and have not set min_sdk in config/nativephp.php. These users would get a lower effective min SDK in their built APK (26 instead of 33). This is generally safe since NativePHP's floor is 26 and the validation already enforces it. The config/nativephp.php file itself still defaults to 33 (env('NATIVEPHP_ANDROID_MIN_SDK', 33)) so any user reading the config will get 33 — the PreparesBuild.php fallback of 26 is only a safety net if config resolution fails, making this change very low risk in practice.
  • The real fix belongs in the mobile-camera plugin manifest. The PreparesBuild.php inconsistency is a separate latent bug worth fixing to prevent future confusion.

@shanerbaner82 shanerbaner82 deleted the fix/issue-63-plugin-nativephpmobile-camera-mins-sdk-1774710189 branch March 28, 2026 19:03
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.

plugin nativephp/mobile-camera mins sdk

1 participant