Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.71 Support #108

Merged
merged 19 commits into from
Feb 21, 2023
Merged

0.71 Support #108

merged 19 commits into from
Feb 21, 2023

Conversation

ospfranco
Copy link
Owner

WIP, currently the android build config is valid but header file for the CallInvoker is missing and therefore compilation fails

Takes care of #107

@ospfranco ospfranco marked this pull request as ready for review January 16, 2023 12:11
@ospfranco
Copy link
Owner Author

ospfranco commented Jan 17, 2023

There seems to be some incompatibility between TypeORM and the babel version/preset used in 0.71... can't really tell at the moment what is going on, but if I comment the TypeORM tests the app transpiles and the tests run.

CleanShot 2023-01-17 at 08 57 29

The solution is to open a ticket on the TypeORM and ask them to take a look but that could takes months to resolve

@ospfranco
Copy link
Owner Author

A related issue: babel/babel#13742

@ospfranco
Copy link
Owner Author

Here is a full stack trace for the babel error:

 LOG  Running "QuickSQLiteExample" with {"rootTag":1,"initialProps":{}}
error: node_modules/typeorm/browser/schema-builder/RdbmsSchemaBuilder.js: /Users/osp/Developer/react-native-quick-sqlite/example/node_modules/typeorm/browser/schema-builder/RdbmsSchemaBuilder.js: Couldn't find a Program
 ERROR  [Error: TransformError node_modules/typeorm/browser/schema-builder/RdbmsSchemaBuilder.js: /Users/osp/Developer/react-native-quick-sqlite/example/node_modules/typeorm/browser/schema-builder/RdbmsSchemaBuilder.js: Couldn't find a Program]
Error: /Users/osp/Developer/react-native-quick-sqlite/example/node_modules/typeorm/browser/schema-builder/RdbmsSchemaBuilder.js: Couldn't find a Program
    at Scope.getProgramParent (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/scope/index.js:768:11)
    at Scope.crawl (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/scope/index.js:686:32)
    at Scope.init (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/scope/index.js:676:12)
    at NodePath.setScope (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:122:30)
    at NodePath.setContext (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:134:8)
    at NodePath.popContext (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:192:10)
    at TraversalContext.visitQueue (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:109:12)
    at TraversalContext.visitMultiple (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at traverse (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:50:34)
    at Function.traverse.hasType (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/core/node_modules/@babel/traverse/lib/index.js:86:3)
    at BlockScoping.wrapClosure (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/plugin-transform-block-scoping/lib/index.js:469:37)
    at BlockScoping.run (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/plugin-transform-block-scoping/lib/index.js:335:12)
    at PluginPass.Loop (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@babel/plugin-transform-block-scoping/lib/index.js:59:38)
    at newFn (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:159:21)
    at NodePath._call (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:84:31)
    at TraversalContext.visitQueue (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitMultiple (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:90:52)
    at TraversalContext.visitQueue (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitSingle (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:72:19)
    at TraversalContext.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:121:19)
    at traverseNode (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:90:52)
    at TraversalContext.visitQueue (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitMultiple (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:90:52)
    at TraversalContext.visitQueue (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitSingle (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:72:19)
    at TraversalContext.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:121:19)
    at traverseNode (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:90:52)
    at TraversalContext.visitQueue (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitMultiple (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:90:52)
    at TraversalContext.visitQueue (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:96:16)
    at TraversalContext.visitMultiple (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:67:17)
    at TraversalContext.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/context.js:119:19)
    at traverseNode (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
    at NodePath.visit (/Users/osp/Developer/react-native-quick-sqlite/example/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:90:52)

I've already tried de-duping but that does not seem to work

@vinigr
Copy link

vinigr commented Jan 21, 2023

I'm having a duplicate class error on android when I try to use the lib in a project that uses react-native-safe-area-context.

> Task :app:mergeLibDexDebug FAILED ERROR:C:\projetos\AwesomeProject\node_modules\react-native-quick-sqlite\android\build\.transforms\a586075c3b2770e3aabc309761ccc742\transformed\classes\classes.dex: D8: Type com.facebook.react.viewmanagers.RNCSafeAreaProviderManagerDelegate is defined multiple times: C:\projetos\AwesomeProject\node_modules\react-native-quick-sqlite\android\build\.transforms\a586075c3b2770e3aabc309761ccc742\transformed\classes\classes.dex, C:\projetos\AwesomeProject\node_modules\react-native-safe-area-context\android\build\.transforms\d8076d2becb3029cf0d5a6b809b687ed\transformed\classes\classes.dex com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Type com.facebook.react.viewmanagers.RNCSafeAreaProviderManagerDelegate is defined multiple times: C:\projetos\AwesomeProject\node_modules\react-native-quick-sqlite\android\build\.transforms\a586075c3b2770e3aabc309761ccc742\transformed\classes\classes.dex, C:\projetos\AwesomeProject\node_modules\react-native-safe-area-context\android\build\.transforms\d8076d2becb3029cf0d5a6b809b687ed\transformed\classes\classes.dex

@ErHarinderSingh
Copy link

@ospfranco same duplicate class error with
https://www.npmjs.com/package/@react-native-community/slider

@ospfranco
Copy link
Owner Author

ospfranco commented Jan 23, 2023

ok, so I just got confirmation that libraries will need to be updated and support only >= 0.71. So, I'm going to stop worrying about conflicts with the other sources and each one will have to be updated independently.

@janicduplessis
Copy link

I was able to get this working with this patch https://github.com/Expensify/App/blob/3e39b3fba33f8f23cbf744073fb3076c5468ce30/patches/react-native-quick-sqlite%2B7.0.0.patch. The duplicate class issue was caused by this line https://github.com/ospfranco/react-native-quick-sqlite/pull/108/files#diff-197b190e4a3512994d2cebed8aff5479ff88e136b8cc7a4b148ec9c3945bd65aR53. Removing it works. I was also able to simplify and remove some more code from build.gradle.

Note that this is testing using old arch, I haven't tried with new arch enabled but I assume it should work fine. This is also not backwards compatible with <0.71.

@ospfranco
Copy link
Owner Author

I was able to get this working with this patch Expensify/App@3e39b3f/patches/react-native-quick-sqlite%2B7.0.0.patch. The duplicate class issue was caused by this line #108 (files). Removing it works. I was also able to simplify and remove some more code from build.gradle.

Note that this is testing using old arch, I haven't tried with new arch enabled but I assume it should work fine. This is also not backwards compatible with <0.71.

I also tried removing the apply but I'm not 100% sure it is the right move, since unless the app has been properly configured or there is another library importing things might break? I'm not sure though...

@janicduplessis
Copy link

I think the plugin is supposed to be used only for apps and not libraries, my guess is the duplicate classes are caused by codegen being ran twice. I checked reanimated which has 0.71 support and they dont use the plugin in their build.gradle.

@vinigr
Copy link

vinigr commented Jan 27, 2023

The react-native-mmkv library was facing the same issue and with this change mrousavy/react-native-mmkv#506 is building without errors. Applying the same to quick-sqlite also compiles without errors

@panda0603
Copy link

panda0603 commented Jan 28, 2023

@ospfranco I'm still getting following error for 7.0.0, with RN 0.71.1. I have a question, is turning on new arch mandatory for RN 0.71? I thought it was optional.

> Configure project :react-native-quick-sqlite
react-native-quick-sqlite: node_modules/ found at: .../node_modules

FAILURE: Build failed with an exception.

* Where:
Build file '.../node_modules/react-native-quick-sqlite/android/build.gradle' line: 201

* What went wrong:
A problem occurred evaluating project ':react-native-quick-sqlite'.
> Expected directory '.../node_modules/react-native/android' to contain exactly one file, however, it contains no files.

@ospfranco
Copy link
Owner Author

@panda0603 you need to use 7.0.0-beta0. And, I'm not sure yet if new arch is required, I copied the build.gradle from another project.

@ospfranco
Copy link
Owner Author

A new version is out 8.0.0-beta1, it seems it doesn't clash with the other packages anymore. Thanks, @janicduplessis!

If fabric needs to be enabled I'm not 100% sure yet, I will try to remove it and see what happens (or you can patch-package yourself).

Repository owner deleted a comment from ErHarinderSingh Jan 28, 2023
@only1chi
Copy link

only1chi commented Feb 7, 2023

@ospfranco I'm still getting following error for 7.0.0, with RN 0.71.1. I have a question, is turning on new arch mandatory for RN 0.71? I thought it was optional.

> Configure project :react-native-quick-sqlite
react-native-quick-sqlite: node_modules/ found at: .../node_modules

FAILURE: Build failed with an exception.

* Where:
Build file '.../node_modules/react-native-quick-sqlite/android/build.gradle' line: 201

* What went wrong:
A problem occurred evaluating project ':react-native-quick-sqlite'.
> Expected directory '.../node_modules/react-native/android' to contain exactly one file, however, it contains no files.

I have the same exact issue with @panda0603.
The problem is that I'm actually trying to build with RN 0.71.2, WITHOUT new architecture.
I tried version 8.0.0-beta1, but this expects new architecture to be enabled.

@ospfranco ospfranco mentioned this pull request Feb 8, 2023
@ospfranco
Copy link
Owner Author

@only1chi sorry, no time to test, patch-package it yourself and see if it works.

@only1chi
Copy link

only1chi commented Feb 9, 2023

RN 0.71 support #107

I was able to get a working react-native-quick-sqlite/android/build.gradle.
It looks like this.

import java.nio.file.Paths

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
    mavenCentral()
    google()
  }

  dependencies {
    classpath("com.android.tools.build:gradle:7.2.2")
  }
}

def resolveBuildType() {
    Gradle gradle = getGradle()
    String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()

    return tskReqStr.contains('Release') ? 'release' : 'debug'
}

def isNewArchitectureEnabled() {
  // To opt-in for the New Architecture, you can either:
  // - Set `newArchEnabled` to true inside the `gradle.properties` file
  // - Invoke gradle with `-newArchEnabled=true`
  // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
  return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

// if (!isNewArchitectureEnabled()) {
//   throw new Exception("react-native-quick-sqlite requires the new architecture to build. Make sure you're running react-native 0.71 or higher and have enabled the new architecture in settings.gradle, then clean and rebuild.")
// }
if (isNewArchitectureEnabled()) {
  apply plugin: 'com.facebook.react'
}
apply plugin: 'com.android.library'

static def findNodeModulePath(baseDir, packageName) {
  def basePath = baseDir.toPath().normalize()
  // Node's module resolution algorithm searches up to the root directory,
  // after which the base path will be null
  while (basePath) {
    def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
    if (candidatePath.toFile().exists()) {
      return candidatePath.toString()
    }
    basePath = basePath.getParent()
  }
  return null
}

def findNodeModulePath(packageName) {
  // Don't start in the project dir, as its path ends with node_modules/react-native-gesture-handler/android
  // we want to go two levels up, so we end up in the first_node modules and eventually
  // search upwards if the package is not found there
  return findNodeModulePath(projectDir.toPath().parent.parent.toFile(), packageName)
}

def SQLITE_FLAGS = rootProject.properties['quickSqliteFlags']

def safeExtGet(prop, fallback) {
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def reactNativeArchitectures() {
  def value = project.getProperties().get("reactNativeArchitectures")
  return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def REACT_NATIVE_DIR = findNodeModulePath("react-native")

repositories {
  mavenCentral()
}

android {
  
  compileSdkVersion safeExtGet("compileSdkVersion", 28)
  
  // Used to override the NDK path/version on internal CI or by allowing
  // users to customize the NDK path/version from their root project (e.g. for M1 support)
  if (rootProject.hasProperty("ndkPath")) {
    ndkPath rootProject.ext.ndkPath
  }
  if (rootProject.hasProperty("ndkVersion")) {
    ndkVersion rootProject.ext.ndkVersion
  }

  buildFeatures {
    prefab true
  }

  defaultConfig {
    minSdkVersion 21
    targetSdkVersion safeExtGet('targetSdkVersion', 28)
    versionCode 1
    versionName "1.0"
    buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
    externalNativeBuild {
        cmake {
            cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
            abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
            arguments '-DANDROID_STL=c++_shared',
              "-DREACT_NATIVE_DIR=${REACT_NATIVE_DIR}",
              "-DSQLITE_FLAGS='${SQLITE_FLAGS ? SQLITE_FLAGS : ''}'"
            abiFilters (*reactNativeArchitectures())
        }
    }
    
  }
  
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  externalNativeBuild {
    cmake {
      path "CMakeLists.txt"
    }
  }

  packagingOptions {
    doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
    excludes = [
            "META-INF",
            "META-INF/**",
            "**/libjsi.so",
            "**/libreact_nativemodule_core.so",
            "**/libturbomodulejsijni.so"
    ]
  }
}

dependencies {
  //noinspection GradleDynamicVersion
//   implementation 'com.facebook.react:react-native:+'
  implementation 'com.facebook.react:react-android:+'
}

// Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
tasks.whenTaskAdded { task ->
  if (task.name.contains("configureCMakeDebug")) {
    rootProject.getTasksByName("packageReactNdkDebugLibs", true).forEach {
      task.dependsOn(it)
    }
  }
  // We want to add a dependency for both configureCMakeRelease and configureCMakeRelWithDebInfo
  if (task.name.contains("configureCMakeRel")) {
    rootProject.getTasksByName("packageReactNdkReleaseLibs", true).forEach {
      task.dependsOn(it)
    }
  }
}

@ospfranco
Copy link
Owner Author

ospfranco commented Feb 11, 2023

@only1chi thanks for the gradle file, it indeed seems to work. It is published under 8.0.0-beta.2 and wait for feedback from other users

@only1chi
Copy link

@only1chi thanks for the gradle file, it indeed seems to work. It is published under 8.0.0-beta.2 and wait for feedback from other users

Thank you!

ReactAndroid::jsi
ReactAndroid::turbomodulejsijni
ReactAndroid::react_nativemodule_core
ReactAndroid::hermes_executor
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ospfranco this library is awesome, thanks for taking the time! From my initial tests SELECTs seem to be around 3-5x faster for 100k records vs all the bridge-based libraries. Bulk insert transactions might even be 8x faster in some cases.

I had an error getting the 8.0.0-beta.2 release working with a JSC-based app:

Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: dlopen failed: library "libhermes_executor.so" not found

I borrowed this idea from expo-modules-core but think it could be fixed by doing something like:

if(${USE_HERMES})
  set(JSEXECUTOR_LIB ReactAndroid::hermes_executor)
else()
  set(JSEXECUTOR_LIB ReactAndroid::jscexecutor)
endif()

target_link_libraries(
  ${PACKAGE_NAME}
  ${LOG_LIB}
  fbjni::fbjni
  ReactAndroid::jsi
  ReactAndroid::turbomodulejsijni
  ReactAndroid::react_nativemodule_core
  ${JSEXECUTOR_LIB}
  android
)

@ospfranco
Copy link
Owner Author

@mjmasn thanks a lot, that works. A new version is published under 8.0.0-beta.3

@ospfranco ospfranco merged commit 4d21bb6 into main Feb 21, 2023
@ospfranco ospfranco deleted the 0.71 branch February 21, 2023 19:27
@KoalaSat
Copy link

Thanks for your effort!

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.

8 participants