Skip to content

Commit 93fe8d2

Browse files
satya164atlj
authored andcommitted
refactor: drop Android.mk and support for old versions of React Native for new architecture
As the new architecture is constantly a moving target, we only plan to keep support for latest version of React Native when using new architecture until its stable. So this change removes support for React Native 0.68 using Android.mk for the new architecture
1 parent 3d58cf5 commit 93fe8d2

File tree

10 files changed

+1
-232
lines changed

10 files changed

+1
-232
lines changed

packages/create-react-native-library/src/index.ts

-12
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ const SWIFT_FILES = {
7676
view_legacy: path.resolve(__dirname, '../templates/swift-view-legacy'),
7777
} as const;
7878

79-
const CPP_VIEW_FILES = {
80-
// view_legacy does NOT need component registration
81-
view_mixed: path.resolve(__dirname, '../templates/cpp-view-mixed'),
82-
view_new: path.resolve(__dirname, '../templates/cpp-view-new'),
83-
} as const;
84-
8579
type ArgName =
8680
| 'slug'
8781
| 'description'
@@ -747,12 +741,6 @@ async function create(argv: yargs.Arguments<any>) {
747741
await copyDir(CPP_FILES, folder);
748742
await fs.remove(path.join(folder, 'ios', `${options.project.name}.m`));
749743
}
750-
751-
if (moduleType === 'view') {
752-
if (arch === 'new' || arch === 'mixed') {
753-
await copyDir(CPP_VIEW_FILES[`${moduleType}_${arch}`], folder);
754-
}
755-
}
756744
}
757745

758746
if (example !== 'none') {

packages/create-react-native-library/templates/cpp-view-mixed/android/Android.mk

-45
This file was deleted.

packages/create-react-native-library/templates/cpp-view-mixed/android/registration.cpp

-18
This file was deleted.

packages/create-react-native-library/templates/cpp-view-new/android/Android.mk

-45
This file was deleted.

packages/create-react-native-library/templates/cpp-view-new/android/registration.cpp

-18
This file was deleted.

packages/create-react-native-library/templates/java-view-mixed/android/src/newarch/{%- project.name %}ViewManagerSpec.java

-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,8 @@
88
import com.facebook.react.uimanager.ViewManagerDelegate;
99
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate;
1010
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface;
11-
import com.facebook.soloader.SoLoader;
1211

1312
public abstract class <%- project.name -%>ViewManagerSpec<T extends View> extends SimpleViewManager<T> implements <%- project.name -%>ViewManagerInterface<T> {
14-
static {
15-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
16-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION);
17-
}
18-
}
19-
2013
private final ViewManagerDelegate<T> mDelegate;
2114

2215
public <%- project.name -%>ViewManagerSpec() {

packages/create-react-native-library/templates/java-view-new/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}ViewManager.java

-7
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,12 @@
1111
import com.facebook.react.uimanager.annotations.ReactProp;
1212
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate;
1313
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface;
14-
import com.facebook.soloader.SoLoader;
1514

1615
@ReactModule(name = <%- project.name -%>ViewManager.NAME)
1716
public class <%- project.name -%>ViewManager extends SimpleViewManager<<%- project.name -%>View> implements <%- project.name -%>ViewManagerInterface<<%- project.name -%>View> {
1817

1918
public static final String NAME = "<%- project.name -%>View";
2019

21-
static {
22-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
23-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION);
24-
}
25-
}
26-
2720
private final ViewManagerDelegate<<%- project.name -%>View> mDelegate;
2821

2922
public <%- project.name -%>ViewManager() {

packages/create-react-native-library/templates/kotlin-view-mixed/android/src/newarch/{%- project.name %}ViewManagerSpec.kt

-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.facebook.react.uimanager.SimpleViewManager
77
import com.facebook.react.uimanager.ViewManagerDelegate
88
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate
99
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface
10-
import com.facebook.soloader.SoLoader
1110

1211
abstract class <%- project.name -%>ViewManagerSpec<T : View> : SimpleViewManager<T>(), <%- project.name -%>ViewManagerInterface<T> {
1312
private val mDelegate: ViewManagerDelegate<T>
@@ -19,12 +18,4 @@ abstract class <%- project.name -%>ViewManagerSpec<T : View> : SimpleViewManager
1918
override fun getDelegate(): ViewManagerDelegate<T>? {
2019
return mDelegate
2120
}
22-
23-
companion object {
24-
init {
25-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
26-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION)
27-
}
28-
}
29-
}
3021
}

packages/create-react-native-library/templates/kotlin-view-new/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}ViewManager.kt

-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.facebook.react.uimanager.ViewManagerDelegate
88
import com.facebook.react.uimanager.annotations.ReactProp
99
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface
1010
import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate
11-
import com.facebook.soloader.SoLoader
1211

1312
@ReactModule(name = <%- project.name -%>ViewManager.NAME)
1413
class <%- project.name -%>ViewManager : SimpleViewManager<<%- project.name -%>View>(),
@@ -38,11 +37,5 @@ class <%- project.name -%>ViewManager : SimpleViewManager<<%- project.name -%>Vi
3837

3938
companion object {
4039
const val NAME = "<%- project.name -%>View"
41-
42-
init {
43-
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
44-
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION)
45-
}
46-
}
4740
}
4841
}

packages/create-react-native-library/templates/native-common/android/build.gradle

+1-64
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,6 @@ apply plugin: "com.android.library"
2727
apply plugin: "kotlin-android"
2828
<% } -%>
2929

30-
<% if (project.view && (project.arch === "new" || project.arch === "mixed")) { -%>
31-
import groovy.json.JsonSlurper
32-
33-
// https://github.com/callstack/react-native-builder-bob/discussions/359
34-
def registrationCompat = {
35-
// The new distribution model uses Maven Central https://reactnative.dev/blog/2023/01/12/version-071
36-
def reactAndroidProject = rootProject.allprojects.find { it.name == 'ReactAndroid' }
37-
if (reactAndroidProject == null) return false
38-
39-
def reactNativeManifest = file("${reactAndroidProject.projectDir}/../package.json")
40-
def reactNativeVersion = new JsonSlurper().parseText(reactNativeManifest.text).version as String
41-
// Fabric was introduced at [email protected], full CMake support were introduced at [email protected]
42-
// Use Android.mk for compatibility with [email protected]/0.69
43-
reactNativeVersion.matches('(0.68.*|0.69.*)')
44-
}()
45-
46-
def codegenViewLibraryName = "<%- project.name + 'View' -%>"
47-
def codegenViewModuleName = {
48-
// Autolink for Fabric uses codegenConfig.name in package.json since [email protected]
49-
// Use codegenViewLibraryName for compatibility with [email protected]/0.69
50-
def libraryManifestJson = new JsonSlurper().parseText(file("$projectDir/../package.json").text)
51-
registrationCompat ? codegenViewLibraryName : libraryManifestJson.codegenConfig.name
52-
}()
53-
<% } -%>
54-
55-
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
56-
5730
if (isNewArchitectureEnabled()) {
5831
apply plugin: "com.facebook.react"
5932
}
@@ -86,7 +59,7 @@ android {
8659
}
8760
}
8861

89-
<% if (project.cpp || (project.view && (project.arch === "new" || project.arch === "mixed"))) { -%>
62+
<% if (project.cpp) { -%>
9063
ndkVersion getExtOrDefault("ndkVersion")
9164
<% } -%>
9265
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
@@ -96,9 +69,6 @@ android {
9669
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
9770
<% if (project.arch === "new" || project.arch === "mixed") { -%>
9871
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
99-
<% if (project.view) { -%>
100-
buildConfigField "String", "CODEGEN_MODULE_REGISTRATION", (isNewArchitectureEnabled() && registrationCompat ? "\"${codegenViewModuleName}_registration\"" : "null")
101-
<% } -%>
10272
<% } -%>
10373

10474
<% if (project.cpp) { -%>
@@ -108,25 +78,6 @@ android {
10878
abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
10979
}
11080
}
111-
<% } else if (project.view && (project.arch === "new" || project.arch === "mixed")) { -%>
112-
if (isNewArchitectureEnabled() && registrationCompat) {
113-
def reactAndroidProject = project(':ReactAndroid')
114-
externalNativeBuild {
115-
ndkBuild {
116-
arguments "APP_PLATFORM=android-21",
117-
"APP_STL=c++_shared",
118-
"NDK_TOOLCHAIN_VERSION=clang",
119-
"GENERATED_SRC_DIR=$buildDir/generated/source", // for react_codegen_* in this library's codegen/jni
120-
"PROJECT_BUILD_DIR=${appProject.buildDir}", // for REACT_NDK_EXPORT_DIR in ReactAndroid's Android-prebuilt.mk
121-
"REACT_ANDROID_DIR=${reactAndroidProject.projectDir}",
122-
"REACT_ANDROID_BUILD_DIR=${reactAndroidProject.buildDir}",
123-
"CODEGEN_MODULE_NAME=$codegenViewModuleName"
124-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
125-
cppFlags "-std=c++17"
126-
targets "${codegenViewModuleName}_registration"
127-
}
128-
}
129-
}
13081
<% } -%>
13182
}
13283
<% if (project.cpp) { -%>
@@ -136,16 +87,6 @@ android {
13687
path "CMakeLists.txt"
13788
}
13889
}
139-
<% } else if (project.view && (project.arch === "new" || project.arch === "mixed")) { -%>
140-
141-
if (isNewArchitectureEnabled() && registrationCompat) {
142-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
143-
externalNativeBuild {
144-
ndkBuild {
145-
path "Android.mk"
146-
}
147-
}
148-
}
14990
<% } -%>
15091
<% if (project.arch === "new" || project.arch === "mixed") { -%>
15192

@@ -221,11 +162,7 @@ dependencies {
221162
if (isNewArchitectureEnabled()) {
222163
react {
223164
jsRootDir = file("../src/")
224-
<% if (project.view) { -%>
225-
libraryName = codegenViewLibraryName
226-
<% } else { -%>
227165
libraryName = "<%- project.view ? project.name + 'View' : project.name -%>"
228-
<% } -%>
229166
codegenJavaPackageName = "com.<%- project.package -%>"
230167
}
231168
}

0 commit comments

Comments
 (0)