diff --git a/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp b/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp index db2e6c199e4..1e2420d0e5b 100644 --- a/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/cmake-utils/default-app-setup/OnLoad.cpp @@ -29,7 +29,12 @@ #include #include +#if __has_include("") +#define AUTOLINKING_AVAILABLE 1 #include +#else +#define AUTOLINKING_AVAILABLE 0 +#endif #include #include #include @@ -56,8 +61,10 @@ void registerComponents( REACT_NATIVE_APP_COMPONENT_REGISTRATION(registry); #endif +#if AUTOLINKING_AVAILABLE // And we fallback to the components autolinked autolinking_registerProviders(registry); +#endif } std::shared_ptr cxxModuleProvider( @@ -71,8 +78,12 @@ std::shared_ptr cxxModuleProvider( // return std::make_shared(jsInvoker); // } +#if AUTOLINKING_AVAILABLE // And we fallback to the CXX module providers autolinked return autolinking_cxxModuleProvider(name, jsInvoker); +#endif + + return nullptr; } std::shared_ptr javaModuleProvider( @@ -101,10 +112,12 @@ std::shared_ptr javaModuleProvider( return module; } +#if AUTOLINKING_AVAILABLE // And we fallback to the module providers autolinked if (auto module = autolinking_ModuleProvider(name, params)) { return module; } +#endif return nullptr; }