Skip to content

Commit

Permalink
fix: new arch build (#183)
Browse files Browse the repository at this point in the history
* fix: android files incorrect app name, bumped some packages

* chore: turned off newArch on android, change reanimated version

* chore: android new arch files formatting fixed
  • Loading branch information
mateki0 committed Jan 16, 2023
1 parent 1123ae4 commit 583fbee
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import java.lang.reflect.InvocationTargetException;
import java.util.List;

import com.facebook.react.bridge.JSIModulePackage; // <- add
import com.swmansion.reanimated.ReanimatedJSIModulePackage; // <- add

public class MainApplication extends Application implements ReactApplication {


Expand All @@ -40,11 +37,6 @@ protected List<ReactPackage> getPackages() {
protected String getJSMainModuleName() {
return "index";
}

@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage(); // <- add
}
};

private final ReactNativeHost mNewArchitectureNativeHost =
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
include $(CLEAR_VARS)
LOCAL_PATH := $(THIS_DIR)
# You can customize the name of your application .so file here.
LOCAL_MODULE := rndiffapp_appmodules
LOCAL_MODULE := example_appmodules
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "MainApplicationModuleProvider.h"
#include <rncore.h>

namespace facebook {
namespace react {

std::shared_ptr<TurboModule> MainApplicationModuleProvider(
const std::string moduleName,
const JavaTurboModule::InitParams &params) {
Expand All @@ -16,5 +18,6 @@ std::shared_ptr<TurboModule> MainApplicationModuleProvider(
// return rncore_ModuleProvider(moduleName, params);
return rncore_ModuleProvider(moduleName, params);
}

} // namespace react
} // namespace facebook
45 changes: 11 additions & 34 deletions example/android/app/src/main/jni/MainApplicationModuleProvider.h
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
#include "MainApplicationTurboModuleManagerDelegate.h"
#include "MainApplicationModuleProvider.h"
#pragma once

#include <memory>
#include <string>
#include <ReactCommon/JavaTurboModule.h>

namespace facebook {
namespace react {
jni::local_ref<MainApplicationTurboModuleManagerDelegate::jhybriddata>
MainApplicationTurboModuleManagerDelegate::initHybrid(
jni::alias_ref<jhybridobject>) {
return makeCxxInstance();
}
void MainApplicationTurboModuleManagerDelegate::registerNatives() {
registerHybrid({
makeNativeMethod(
"initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid),
makeNativeMethod(
"canCreateTurboModule",
MainApplicationTurboModuleManagerDelegate::canCreateTurboModule),
});
}
std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const std::shared_ptr<CallInvoker> jsInvoker) {
// Not implemented yet: provide pure-C++ NativeModules here.
return nullptr;
}
std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const JavaTurboModule::InitParams &params) {
return MainApplicationModuleProvider(name, params);
}
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
std::string name) {
return getTurboModule(name, nullptr) != nullptr ||
getTurboModule(name, {.moduleName = name}) != nullptr;
}

std::shared_ptr<TurboModule> MainApplicationModuleProvider(
const std::string moduleName,
const JavaTurboModule::InitParams &params);

} // namespace react
} // namespace facebook
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "MainApplicationTurboModuleManagerDelegate.h"
#include "MainApplicationModuleProvider.h"

namespace facebook {
namespace react {

jni::local_ref<MainApplicationTurboModuleManagerDelegate::jhybriddata>
MainApplicationTurboModuleManagerDelegate::initHybrid(
jni::alias_ref<jhybridobject>) {
return makeCxxInstance();
}
void MainApplicationTurboModuleManagerDelegate::registerNatives() {
registerHybrid({
makeNativeMethod(
"initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid),
makeNativeMethod(
"canCreateTurboModule",
MainApplicationTurboModuleManagerDelegate::canCreateTurboModule),
});
}
std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const std::shared_ptr<CallInvoker> jsInvoker) {
// Not implemented yet: provide pure-C++ NativeModules here.
return nullptr;
}
std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const JavaTurboModule::InitParams &params) {
return MainApplicationModuleProvider(name, params);
}
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
std::string name) {
return getTurboModule(name, nullptr) != nullptr ||
getTurboModule(name, {.moduleName = name}) != nullptr;
}

} // namespace react
} // namespace facebook
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
#include <string>
#include <ReactCommon/TurboModuleManagerDelegate.h>
#include <fbjni/fbjni.h>

namespace facebook {
namespace react {

class MainApplicationTurboModuleManagerDelegate
: public jni::HybridClass<
MainApplicationTurboModuleManagerDelegate,
TurboModuleManagerDelegate> {
public:
// Adapt it to the package you used for your Java class.
static constexpr auto kJavaDescriptor =
"Lcom/rndiffapp/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
"Lcom/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>);
static void registerNatives();
std::shared_ptr<TurboModule> getTurboModule(
Expand All @@ -26,5 +28,6 @@ class MainApplicationTurboModuleManagerDelegate
*/
bool canCreateTurboModule(std::string name);
};

} // namespace react
} // namespace facebook
3 changes: 3 additions & 0 deletions example/android/app/src/main/jni/MainComponentsRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include <fbjni/fbjni.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <react/renderer/components/rncore/ComponentDescriptors.h>

namespace facebook {
namespace react {

MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {}
std::shared_ptr<ComponentDescriptorProviderRegistry const>
MainComponentsRegistry::sharedProviderRegistry() {
Expand Down Expand Up @@ -44,5 +46,6 @@ void MainComponentsRegistry::registerNatives() {
makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid),
});
}

} // namespace react
} // namespace facebook
5 changes: 4 additions & 1 deletion example/android/app/src/main/jni/MainComponentsRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
#include <fbjni/fbjni.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>

namespace facebook {
namespace react {

class MainComponentsRegistry
: public facebook::jni::HybridClass<MainComponentsRegistry> {
public:
// Adapt it to the package you used for your Java class.
constexpr static auto kJavaDescriptor =
"Lcom/rndiffapp/newarchitecture/components/MainComponentsRegistry;";
"Lcom/example/newarchitecture/components/MainComponentsRegistry;";
static void registerNatives();
MainComponentsRegistry(ComponentFactory *delegate);
private:
Expand All @@ -20,5 +22,6 @@ class MainComponentsRegistry
jni::alias_ref<jclass>,
ComponentFactory *delegate);
};

} // namespace react
} // namespace facebook
1 change: 1 addition & 0 deletions example/android/app/src/main/jni/OnLoad.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <fbjni/fbjni.h>
#include "MainApplicationTurboModuleManagerDelegate.h"
#include "MainComponentsRegistry.h"

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
return facebook::jni::initialize(vm, [] {
facebook::react::MainApplicationTurboModuleManagerDelegate::
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ PODS:
- React-perflogger (= 0.68.4)
- RNCMaskedView (0.2.8):
- React-Core
- RNGestureHandler (2.1.1):
- RNGestureHandler (2.8.0):
- React-Core
- RNReanimated (2.13.0):
- DoubleConversion
Expand Down Expand Up @@ -588,7 +588,7 @@ SPEC CHECKSUMS:
React-runtimeexecutor: 088723cf020113e64736a709f52719dbb359c73e
ReactCommon: 1a4f19f3b4366feec03a98bdbb200b6085c5000f
RNCMaskedView: bc0170f389056201c82a55e242e5d90070e18e5a
RNGestureHandler: e1ad51d31a580755079d5124d3ab66f0fcaa8311
RNGestureHandler: 62232ba8f562f7dea5ba1b3383494eb5bf97a4d3
RNReanimated: b21b362b4b8ca921932e8b1718e88cf3a36f157e
RNScreens: 34cc502acf1b916c582c60003dc3089fa01dc66d
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"@reduxjs/toolkit": "^1.7.1",
"react": "17.0.2",
"react-native": "0.68.4",
"react-native-gesture-handler": "2.1.1",
"react-native-gesture-handler": "2.8.0",
"react-native-reanimated": "^2.10.0",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.14.0",
"react-native-screens": "^3.18.2",
"react-redux": "^7.2.6"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5871,10 +5871,10 @@ react-native-codegen@^0.0.18:
jscodeshift "^0.13.1"
nullthrows "^1.1.1"

react-native-gesture-handler@2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.1.1.tgz#1d417bc7b551ec76129ce09861b3a01622b4ef99"
integrity sha512-1+qMhsXKKWTPAFi2ZY8rEhP/4xIevWNb1zLU9MzJkr7tRIEW4G+ipxjLyCw+7hQeqeeIbyZ8kkTyHAUuwTrHDA==
react-native-gesture-handler@2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.8.0.tgz#ef9857871c10663c95a51546225b6e00cd4740cf"
integrity sha512-poOSfz/w0IyD6Qwq7aaIRRfEaVTl1ecQFoyiIbpOpfNTjm2B1niY2FLrdVQIOtIOe+K9nH55Qal04nr4jGkHdQ==
dependencies:
"@egjs/hammerjs" "^2.0.17"
hoist-non-react-statics "^3.3.0"
Expand Down Expand Up @@ -5905,7 +5905,7 @@ react-native-safe-area-context@^3.3.2:
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.4.1.tgz#c967a52903d55fe010b2428e5368b42f1debc0a7"
integrity sha512-xfpVd0CiZR7oBhuwJ2HcZMehg5bjha1Ohu1XHpcT+9ykula0TgovH2BNU0R5Krzf/jBR1LMjR6VabxdlUjqxcA==

react-native-screens@^3.14.0:
react-native-screens@^3.18.2:
version "3.18.2"
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.18.2.tgz#d7ab2d145258d3db9fa630fa5379dc4474117866"
integrity sha512-ANUEuvMUlsYJ1QKukEhzhfrvOUO9BVH9Nzg+6eWxpn3cfD/O83yPBOF8Mx6x5H/2+sMy+VS5x/chWOOo/U7QJw==
Expand Down

0 comments on commit 583fbee

Please sign in to comment.