From f551600a4e7c4f3a8203669710abafc90a7765f9 Mon Sep 17 00:00:00 2001 From: Gary Tokman Date: Mon, 2 Sep 2024 15:33:19 -0400 Subject: [PATCH] fix: make android compile fix: update --- packages/npm/send/android/CMakeLists.txt | 8 +---- packages/npm/send/android/build.gradle | 33 +++++++------------ packages/npm/send/android/cpp-adapter.cpp | 8 ----- .../com/candlefinance/send/SendPackage.kt | 30 ++++++++--------- packages/npm/send/react-native.config.js | 14 ++++---- 5 files changed, 34 insertions(+), 59 deletions(-) delete mode 100644 packages/npm/send/android/cpp-adapter.cpp diff --git a/packages/npm/send/android/CMakeLists.txt b/packages/npm/send/android/CMakeLists.txt index 8fe12f7..1008f9f 100644 --- a/packages/npm/send/android/CMakeLists.txt +++ b/packages/npm/send/android/CMakeLists.txt @@ -6,18 +6,12 @@ set (CMAKE_VERBOSE_MAKEFILE ON) set (CMAKE_CXX_STANDARD 20) # Define C++ library and add all sources -add_library(${PACKAGE_NAME} SHARED - src/main/cpp/cpp-adapter.cpp -) + # Add Nitrogen specs :) include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/send+autolinking.cmake) # Set up local includes -include_directories( - "src/main/cpp" - "../cpp" -) find_library(LOG_LIB log) diff --git a/packages/npm/send/android/build.gradle b/packages/npm/send/android/build.gradle index 34656ee..cb286a3 100644 --- a/packages/npm/send/android/build.gradle +++ b/packages/npm/send/android/build.gradle @@ -1,7 +1,4 @@ buildscript { - // Buildscript is evaluated before everything else so we can't use getExtOrDefault - def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Send_kotlinVersion"] - repositories { google() mavenCentral() @@ -9,8 +6,6 @@ buildscript { dependencies { classpath "com.android.tools.build:gradle:7.2.1" - // noinspection DifferentKotlinGradleVersion - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -24,7 +19,7 @@ def isNewArchitectureEnabled() { } apply plugin: "com.android.library" -apply plugin: "kotlin-android" +apply plugin: 'org.jetbrains.kotlin.android' apply from: '../nitrogen/generated/android/send+autolinking.gradle' if (isNewArchitectureEnabled()) { @@ -49,15 +44,7 @@ def supportsNamespace() { } android { - if (supportsNamespace()) { - namespace "com.candlefinance.send" - - sourceSets { - main { - manifest.srcFile "src/main/AndroidManifestNew.xml" - } - } - } + namespace "com.candlefinance.send" ndkVersion getExtOrDefault("ndkVersion") compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") @@ -70,6 +57,7 @@ android { externalNativeBuild { cmake { cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all" + arguments "-DANDROID_STL=c++_shared" abiFilters (*reactNativeArchitectures()) } } @@ -83,6 +71,7 @@ android { buildFeatures { buildConfig true + prefab true } buildTypes { @@ -103,10 +92,10 @@ android { sourceSets { main { if (isNewArchitectureEnabled()) { - java.srcDirs += [ - "generated/java", - "generated/jni" - ] + java.srcDirs += [ + // React Codegen files + "${project.buildDir}/generated/source/codegen/java" + ] } } } @@ -117,14 +106,14 @@ repositories { google() } -def kotlin_version = getExtOrDefault("kotlinVersion") dependencies { // For < 0.71, this will be from the local maven repo // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + + // Add a dependency on NitroModules implementation project(":react-native-nitro-modules") } @@ -134,4 +123,4 @@ if (isNewArchitectureEnabled()) { libraryName = "Send" codegenJavaPackageName = "com.candlefinance.send" } -} +} \ No newline at end of file diff --git a/packages/npm/send/android/cpp-adapter.cpp b/packages/npm/send/android/cpp-adapter.cpp deleted file mode 100644 index ce2b01e..0000000 --- a/packages/npm/send/android/cpp-adapter.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include "candlefinance-send.h" - -extern "C" -JNIEXPORT jdouble JNICALL -Java_com_candlefinance_send_SendModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) { - return candlefinance_send::multiply(a, b); -} diff --git a/packages/npm/send/android/src/main/java/com/candlefinance/send/SendPackage.kt b/packages/npm/send/android/src/main/java/com/candlefinance/send/SendPackage.kt index 92fd9e0..01a2fe4 100644 --- a/packages/npm/send/android/src/main/java/com/candlefinance/send/SendPackage.kt +++ b/packages/npm/send/android/src/main/java/com/candlefinance/send/SendPackage.kt @@ -1,30 +1,28 @@ package com.candlefinance.send +import android.content.Context +import android.util.Log import com.facebook.react.TurboReactPackage import com.facebook.react.bridge.NativeModule import com.facebook.react.bridge.ReactApplicationContext -import com.facebook.react.module.model.ReactModuleInfo import com.facebook.react.module.model.ReactModuleInfoProvider -import java.util.HashMap +import com.margelo.nitro.core.HybridObjectRegistry -class SendPackage : TurboReactPackage() { +class SendPackage(context: ReactApplicationContext) : TurboReactPackage() { override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? { return null } + init { +// HybridObjectRegistry.registerHybridObjectConstructor("Send") { +// Log.i("YEET", "initializing Send...") +// val f: SendModule = SendModule(Context()) +// Log.i("YEET", "done Send!") +// f +// } + } + override fun getReactModuleInfoProvider(): ReactModuleInfoProvider { - return ReactModuleInfoProvider { - val moduleInfos: MutableMap = HashMap() -// moduleInfos[SendModule.NAME] = ReactModuleInfo( -// SendModule.NAME, -// SendModule.NAME, -// false, // canOverrideExistingModule -// false, // needsEagerInit -// true, // hasConstants -// false, // isCxxModule -// true // isTurboModule -// ) - moduleInfos - } + return ReactModuleInfoProvider { HashMap() } } } diff --git a/packages/npm/send/react-native.config.js b/packages/npm/send/react-native.config.js index d024dd2..7e2adda 100644 --- a/packages/npm/send/react-native.config.js +++ b/packages/npm/send/react-native.config.js @@ -1,12 +1,14 @@ -/** - * @type {import('@react-native-community/cli-types').UserDependencyConfig} - */ module.exports = { dependency: { platforms: { - android: { - cmakeListsPath: 'generated/jni/CMakeLists.txt', - }, + /** + * @type {import('@react-native-community/cli-types').IOSDependencyParams} + */ + ios: {}, + /** + * @type {import('@react-native-community/cli-types').AndroidDependencyParams} + */ + android: {}, }, }, }