Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/sdk/reactNative/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "com.facebook.react"
apply from: "$rootDir/../node_modules/@backtrace/react-native/android/upload-sourcemaps.gradle"

Expand Down Expand Up @@ -72,6 +73,9 @@ def enableProguardInReleaseBuilds = false
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

android {
ndkVersion rootProject.ext.ndkVersion
Expand All @@ -86,6 +90,15 @@ android {
versionCode 1
versionName "1.0"
}

if (isNewArchitectureEnabled()) {
externalNativeBuild {
cmake {
path "src/main/jni/CMakeLists.txt"
version "3.22.1"
}
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactHost;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.soloader.SoLoader;

import java.util.List;

Expand Down Expand Up @@ -61,7 +60,7 @@ public ReactHost getReactHost() {
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, false);
SoLoaderInit.init(this);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for
// this app.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.reactnative

import android.app.Application
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader

object SoLoaderInit {
@JvmStatic
fun init(app: Application) {
// Initializes SoLoader with the merged-JNI mapping so merged libs can be resolved
SoLoader.init(app, OpenSourceMergedSoMapping)
}
}
30 changes: 30 additions & 0 deletions examples/sdk/reactNative/android/app/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# android/app/src/main/jni/CMakeLists.txt

cmake_minimum_required(VERSION 3.18)
project(appmodules LANGUAGES CXX)

find_package(ReactAndroid REQUIRED)

# Define a variable that points to the folder where Codegen files are created
set(
generated_sources_dir
"${CMAKE_BINARY_DIR}/codegen/jni"
)

# Check if the main C++ file generated by Codegen exists.
# This `if` block is the key to the solution.
if(EXISTS "${generated_sources_dir}/react/renderer/components/appmodules/AppModulesJni.cpp")

# If the file exists, then create the library and link it.
add_library(
appmodules
SHARED
"${generated_sources_dir}/react/renderer/components/appmodules/AppModulesJni.cpp"
)

target_link_libraries(
appmodules
ReactAndroid::react_native_modules
)

endif()
7 changes: 6 additions & 1 deletion examples/sdk/reactNative/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
buildToolsVersion = "35.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
buildToolsVersion = "35.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "28.0.13004108"
}
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion examples/sdk/reactNative/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android.useAndroidX=true
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

reactNative.jniLibsMerge.enabled=true
# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading