Skip to content

Commit 9b50a0e

Browse files
committed
fix: attemp to fix android autolink error
1 parent 8d1c213 commit 9b50a0e

19 files changed

+127
-156
lines changed

android/build.gradle

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import java.nio.file.Paths
22

33
buildscript {
4-
ext.safeExtGet = {prop, fallback ->
5-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
6-
}
7-
84
repositories {
95
google()
106
mavenCentral()
11-
gradlePluginPortal()
127
}
138

149
dependencies {
@@ -30,35 +25,32 @@ if (isNewArchitectureEnabled()) {
3025
apply plugin: "com.facebook.react"
3126
}
3227

33-
android {
34-
compileSdkVersion safeExtGet('compileSdkVersion', 30)
35-
buildToolsVersion safeExtGet('buildToolsVersion', '29.0.3')
28+
def getExtOrDefault(name, defaultValue) {
29+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue
30+
}
3631

37-
// Used to override the NDK path/version on internal CI or by allowing
38-
// users to customize the NDK path/version from their root project (e.g. for M1 support)
39-
if (rootProject.hasProperty("ndkPath")) {
40-
ndkPath rootProject.ext.ndkPath
41-
}
42-
if (rootProject.hasProperty("ndkVersion")) {
43-
ndkVersion rootProject.ext.ndkVersion
44-
}
32+
android {
33+
compileSdkVersion getExtOrDefault('compileSdkVersion', 30)
34+
buildToolsVersion getExtOrDefault('buildToolsVersion', '29.0.3')
4535

4636
defaultConfig {
47-
minSdkVersion safeExtGet('minSdkVersion', 21)
48-
targetSdkVersion safeExtGet('targetSdkVersion', 31)
37+
minSdkVersion getExtOrDefault('minSdkVersion', 21)
38+
targetSdkVersion getExtOrDefault('targetSdkVersion', 31)
39+
versionCode 1
40+
versionName "1.0"
4941
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
5042
}
5143

5244
lintOptions {
5345
abortOnError false
5446
}
5547

56-
5748
sourceSets.main {
5849
java {
5950
if (isNewArchitectureEnabled()) {
6051
srcDirs += [
6152
"src/fabric/java",
53+
"${project.buildDir}/generated/source/codegen/java"
6254
]
6355
} else {
6456
srcDirs += [
@@ -70,6 +62,7 @@ android {
7062
}
7163

7264
repositories {
65+
google()
7366
mavenCentral()
7467
}
7568

common/cpp/Android.mk

Lines changed: 0 additions & 25 deletions
This file was deleted.

common/cpp/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.13)
7+
set(CMAKE_VERBOSE_MAKEFILE on)
8+
9+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/progressview/*.cpp)
10+
11+
add_library(
12+
react_codegen_progressview
13+
SHARED
14+
${react_codegen_SRCS}
15+
)
16+
17+
target_include_directories(react_codegen_progressview PUBLIC . react/renderer/components/progressview)
18+
19+
target_link_libraries(
20+
react_codegen_progressview
21+
fbjni
22+
folly_runtime
23+
glog
24+
jsi
25+
react_codegen_rncore
26+
react_debug
27+
react_nativemodule_core
28+
react_render_core
29+
react_render_mapbuffer
30+
react_render_imagemanager
31+
react_render_debug
32+
react_render_graphics
33+
rrc_view
34+
turbomodulejsijni
35+
yoga
36+
)
37+
38+
target_compile_options(
39+
react_codegen_progressview
40+
PRIVATE
41+
-DLOG_TAG=\"ReactNative\"
42+
-fexceptions
43+
-frtti
44+
-std=c++17
45+
-Wall
46+
)

common/cpp/react/renderer/components/progressview/RNCProgressViewShadowNode.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <jsi/jsi.h>
34
#include <react/renderer/components/progressview/Props.h>
45
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
56
#include <react/renderer/components/view/ViewEventEmitter.h>
@@ -12,12 +13,12 @@
1213
namespace facebook {
1314
namespace react {
1415

15-
extern const char RNCProgressViewComponentName[];
16+
JSI_EXPORT extern const char RNCProgressViewComponentName[];
1617

1718
/*
1819
* `ShadowNode` for <RNCProgressView> component.
1920
*/
20-
class RNCProgressViewShadowNode final : public ConcreteViewShadowNode<
21+
JSI_EXPORT class RNCProgressViewShadowNode final : public ConcreteViewShadowNode<
2122
RNCProgressViewComponentName,
2223
RNCProgressViewProps,
2324
ViewEventEmitter,

common/cpp/react/renderer/components/progressview/RNCProgressViewState.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace react {
1515
/*
1616
* State for <RNCProgressView> component.
1717
*/
18-
class RNCProgressViewState final {
18+
class JSI_EXPORT RNCProgressViewState final {
1919
public:
2020
RNCProgressViewState(
2121
ImageSource const &progressImageSource,

fabric-example/.flowconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ untyped-import
6363
untyped-type-import
6464

6565
[version]
66-
^0.176.3
66+
^0.182.0
67+

fabric-example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23+
.cxx/
2324

2425
# Android/IntelliJ
2526
#

fabric-example/.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16

fabric-example/android/app/build.gradle

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: "com.android.application"
22

33
import com.android.build.OutputFile
4+
import org.apache.tools.ant.taskdefs.condition.Os
45

56
/**
67
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -142,22 +143,14 @@ android {
142143
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
143144

144145
if (isNewArchitectureEnabled()) {
145-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
146+
// We configure the CMake build only if you decide to opt-in for the New Architecture.
146147
externalNativeBuild {
147-
ndkBuild {
148-
arguments "APP_PLATFORM=android-21",
149-
"APP_STL=c++_shared",
150-
"NDK_TOOLCHAIN_VERSION=clang",
151-
"GENERATED_SRC_DIR=$buildDir/generated/source",
152-
"PROJECT_BUILD_DIR=$buildDir",
153-
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
154-
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
155-
"NODE_MODULES_DIR=$rootDir/../node_modules"
156-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
157-
cppFlags "-std=c++17"
158-
// Make sure this target name is the same you specify inside the
159-
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
160-
targets "fabricexample_appmodules"
148+
cmake {
149+
arguments "-DPROJECT_BUILD_DIR=$buildDir",
150+
"-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
151+
"-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
152+
"-DNODE_MODULES_DIR=$rootDir/../node_modules",
153+
"-DANDROID_STL=c++_shared"
161154
}
162155
}
163156
if (!enableSeparateBuildPerCPUArchitecture) {
@@ -171,8 +164,8 @@ android {
171164
if (isNewArchitectureEnabled()) {
172165
// We configure the NDK build only if you decide to opt-in for the New Architecture.
173166
externalNativeBuild {
174-
ndkBuild {
175-
path "$projectDir/src/main/jni/Android.mk"
167+
cmake {
168+
path "$projectDir/src/main/jni/CMakeLists.txt"
176169
}
177170
}
178171
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
@@ -194,15 +187,15 @@ android {
194187
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
195188

196189
// Due to a bug inside AGP, we have to explicitly set a dependency
197-
// between configureNdkBuild* tasks and the preBuild tasks.
190+
// between configureCMakeDebug* tasks and the preBuild tasks.
198191
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
199-
configureNdkBuildRelease.dependsOn(preReleaseBuild)
200-
configureNdkBuildDebug.dependsOn(preDebugBuild)
192+
configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
193+
configureCMakeDebug.dependsOn(preDebugBuild)
201194
reactNativeArchitectures().each { architecture ->
202-
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
195+
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
203196
dependsOn("preDebugBuild")
204197
}
205-
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
198+
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
206199
dependsOn("preReleaseBuild")
207200
}
208201
}

fabric-example/android/app/src/main/jni/Android.mk

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)