Skip to content

Mendix 11 / native template 19 compatibility (v1.1.3) - #5

Closed
tmisker wants to merge 6 commits into
mrgroen:mainfrom
tmisker:fix/mendix11-vector-icons
Closed

tmisker wants to merge 6 commits into
mrgroen:mainfrom
tmisker:fix/mendix11-vector-icons

Conversation

@tmisker

@tmisker tmisker commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Makes the widget build and run on Mendix 11.10+ (native template 19+, React Native 0.84, new architecture). Version 1.1.3.

Builds on #4 (v1.1.2); until that one is merged this PR also shows that commit.

Problems on Mendix 11.12 / native template 19.1

  1. Studio Pro fails to bundle the app ("Packaging iOS failed"):
    Unable to resolve module react-native-vector-icons/MaterialCommunityIcons.
    Native template 19 dropped react-native-vector-icons in favour of the scoped @react-native-vector-icons/* packages (only material-icons), while pluggable-widgets-tools still treats react-native-vector-icons as external, so it is neither bundled nor shipped in the .mpk.
  2. Android build fails on react-native-static-safe-area-insets: its build.gradle uses jcenter(), which no longer exists in Gradle 9, and it has no namespace. The package has not been updated since 2022.
  3. Android build fails on react-native-vision-camera 4.6.4 against React Native 0.84.1: getExportedCustomDirectEventTypeConstants return type mismatch and unresolved currentActivity.
  4. Widget crashes on mount with react-native-mmkv 2.x: "Failed to create a new MMKV instance: React Native is not running on-device". mmkv 2.x checks for global.nativeCallSyncHook, which does not exist in bridgeless mode (the default with the new architecture). The message about a remote debugger is misleading.

Changes

  • Icons are drawn with react-native-svg (part of every Mendix native template, external in the tooling) using path data from @mdi/js (pure JS, tree-shaken into the bundle). react-native-vector-icons and its typings are removed. Same Material icons as before; the "night mode off" state is now an outlined moon.
  • react-native-static-safe-area-insets replaced by react-native-safe-area-context (also part of every template and external). The widget wraps itself in a SafeAreaProvider, and the safe-area padding is computed from the insets at render time instead of static module constants. One behaviour change: the bottom inset now also applies on Android (was iOS-only), which is needed with the edge-to-edge setting of template 19.
  • react-native-vision-camera bumped to 4.7.3, the latest 4.x, which contains the React Native 0.8x fixes.
  • react-native-mmkv removed together with the usePreferredCameraDevice hook. The hook only ever read a stored device id; nothing in the widget called its setter, so the preference could never be set and the hook always returned undefined. No behaviour change for users. If a preferred-device setting is wanted later, mmkv 3.x (TurboModule based) works on the new architecture, or the choice could live in a Mendix attribute.
  • The .mpk now declares only @react-native-community/blur and react-native-vision-camera as native dependencies.
  • Version 1.1.3, also in src/package.xml so Studio Pro shows it. README lists the tested versions.
  • Two files formatted with Prettier so npm run lint (and therefore npm run release) passes.

Verification

  • npm run release and npm run lint pass.
  • Full Gradle build of native template 19.1.5 (assembleAppstoreDebug, React Native 0.84.1, new architecture) succeeds.
  • Verified on an Android tablet emulator (Android 16) with Mendix 11.12.4: camera preview, controls, capture with back and front camera; the host app stores the photo.

Note for users on Mendix 11

The nanoflow or JavaScript action that stores the captured file must read it through NativeModules.MxFileSystem (the way NativeMobileResources.TakePicture does in Mendix 11). fetch("file://...") no longer works on Android with the new architecture and fails with "Network request failed".

🤖 Generated with Claude Code

tmisker and others added 6 commits March 24, 2026 12:56
The camera was producing portrait-oriented photos when the tablet was held
landscape, and the captured photo showed more content than what was visible
in the preview. Root cause: SCREEN_WIDTH/SCREEN_HEIGHT were static module-level
values that did not update on rotation, causing screenAspectRatio to be < 1
(portrait) — which doesn't match any landscape camera sensor format.

- Use useWindowDimensions() for reactive dimensions that update on rotation
- Calculate screenAspectRatio as max/min to always be >= 1, matching camera
  sensor formats (e.g. 4:3 = 1.33, 16:9 = 1.77)
- Fix ESLint errors: == → ===, merge duplicate imports in useIsForeground.ts
  and usePreferredCameraDevice.ts
- Fix .eslintrc.js: exclude jest plugin (incompatible with Node 22 / ESLint 8)
- Bump version to 1.1.2

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
`npm run lint` failed on these two files, which also blocked `npm run release`
(prerelease runs lint). Formatting only, no functional change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Studio Pro 11.10+ (native template 19+) no longer ships
react-native-vector-icons: the template moved to the scoped
@react-native-vector-icons/* packages and only includes material-icons.
pluggable-widgets-tools still treats react-native-vector-icons as an
external dependency, so it is neither bundled nor copied into the .mpk.
On Mendix 11.12 every deploy therefore fails in the native bundling step:

  Unable to resolve module react-native-vector-icons/MaterialCommunityIcons
  from .../nativevisioncamera/NativeVisionCamera.ios.js

- Add a small Icon component that draws SVG paths with react-native-svg,
  which is part of every Mendix native template (external, nothing to link)
- Take the path data from @mdi/js (pure JS, tree-shaken into the bundle,
  Apache-2.0): camera flip, flash on/off, HDR on/off, night mode on/off
- Drop react-native-vector-icons and its typings from package.json
- Bump the version to 1.1.3, also in src/package.xml so Studio Pro shows it

Works on older templates (which still had vector-icons) as well as 19+.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…rea-context

react-native-static-safe-area-insets (last release 2022) does not build with
Gradle 9 / AGP 8 as used by Mendix native template 19 (Studio Pro 11.10+):
"Could not find method jcenter()" in its build.gradle, and it has no namespace.

react-native-safe-area-context ships with every Mendix native template and is
treated as external by pluggable-widgets-tools, so the widget no longer has to
declare a native dependency for the safe area at all.

- Wrap the widget in its own SafeAreaProvider so useSafeAreaInsets() works
  regardless of what the host app renders
- Compute the safe area padding from the insets at render time instead of
  static module-level constants; positions that depend on it moved from the
  static StyleSheet into dynamic styles
- The bottom inset is now applied on Android too (previously iOS only), which
  is needed with the edge-to-edge setting of template 19
- Remove the unused SCREEN_WIDTH / SCREEN_HEIGHT constants

Co-Authored-By: Claude Fable 5.1 <[email protected]>
4.6.4 fails to compile against React Native 0.84.1 (native template 19.1):
- CameraViewManager.kt: getExportedCustomDirectEventTypeConstants return type
- CameraViewModule.kt: unresolved reference 'currentActivity'

Both are fixed upstream in 4.7.x; 4.7.3 is the latest 4.x release. Verified
with a full Gradle build of native template 19.1.5 (assembleAppstoreDebug).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@tmisker tmisker closed this Sep 15, 2026
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.

1 participant