Skip to content

Commit

Permalink
fix: make android compile
Browse files Browse the repository at this point in the history
fix: update
  • Loading branch information
gtokman committed Sep 2, 2024
1 parent 9d90e8e commit f551600
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 59 deletions.
8 changes: 1 addition & 7 deletions packages/npm/send/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
33 changes: 11 additions & 22 deletions packages/npm/send/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
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()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -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()) {
Expand All @@ -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")
Expand All @@ -70,6 +57,7 @@ android {
externalNativeBuild {
cmake {
cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
arguments "-DANDROID_STL=c++_shared"
abiFilters (*reactNativeArchitectures())
}
}
Expand All @@ -83,6 +71,7 @@ android {

buildFeatures {
buildConfig true
prefab true
}

buildTypes {
Expand All @@ -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"
]
}
}
}
Expand All @@ -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")
}

Expand All @@ -134,4 +123,4 @@ if (isNewArchitectureEnabled()) {
libraryName = "Send"
codegenJavaPackageName = "com.candlefinance.send"
}
}
}
8 changes: 0 additions & 8 deletions packages/npm/send/android/cpp-adapter.cpp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<String, ReactModuleInfo> = HashMap()
// moduleInfos[SendModule.NAME] = ReactModuleInfo(
// SendModule.NAME,
// SendModule.NAME,
// false, // canOverrideExistingModule
// false, // needsEagerInit
// true, // hasConstants
// false, // isCxxModule
// true // isTurboModule
// )
moduleInfos
}
return ReactModuleInfoProvider { HashMap() }
}
}
14 changes: 8 additions & 6 deletions packages/npm/send/react-native.config.js
Original file line number Diff line number Diff line change
@@ -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: {},
},
},
}

0 comments on commit f551600

Please sign in to comment.