Skip to content

Commit d01ba5a

Browse files
authored
Merge pull request #694 from Iterable/new-arch/MOB-11955-configure-new-architecture
[MOB-11955] configure-new-architecture
2 parents 3d8cffc + b042322 commit d01ba5a

File tree

7 files changed

+324
-67
lines changed

7 files changed

+324
-67
lines changed

android/build.gradle

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
buildscript {
2-
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNIterable_kotlinVersion"]
2+
ext.getExtOrDefault = {name ->
3+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNIterable_' + name]
4+
}
45

56
repositories {
67
google()
78
mavenCentral()
89
}
910

1011
dependencies {
11-
classpath "com.android.tools.build:gradle:7.2.1"
12+
classpath "com.android.tools.build:gradle:8.7.2"
1213
// noinspection DifferentKotlinGradleVersion
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
1415
}
1516
}
1617

17-
def reactNativeArchitectures() {
18-
def value = rootProject.getProperties().get("reactNativeArchitectures")
19-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20-
}
21-
2218
def isNewArchitectureEnabled() {
2319
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
2420
}
@@ -63,7 +59,11 @@ android {
6359
defaultConfig {
6460
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
6561
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
62+
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
63+
}
6664

65+
buildFeatures {
66+
buildConfig true
6767
}
6868

6969
buildTypes {
@@ -80,6 +80,19 @@ android {
8080
sourceCompatibility JavaVersion.VERSION_1_8
8181
targetCompatibility JavaVersion.VERSION_1_8
8282
}
83+
84+
sourceSets {
85+
main {
86+
if (isNewArchitectureEnabled()) {
87+
java.srcDirs += ['src/newarch']
88+
} else {
89+
java.srcDirs += ['src/oldarch']
90+
}
91+
}
92+
}
93+
94+
// Add this to match the Iterable SDK group ID
95+
group = "com.iterable"
8396
}
8497

8598
repositories {
@@ -90,10 +103,7 @@ repositories {
90103
def kotlin_version = getExtOrDefault("kotlinVersion")
91104

92105
dependencies {
93-
// For < 0.71, this will be from the local maven repo
94-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
95-
//noinspection GradleDynamicVersion
96-
implementation "com.facebook.react:react-native:+"
106+
implementation "com.facebook.react:react-android"
97107
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98108
api "com.iterable:iterableapi:3.5.2"
99109
// api project(":iterableapi") // links to local android SDK repo rather than by release

android/gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
RNIterable_kotlinVersion=1.7.0
2-
RNIterable_minSdkVersion=21
3-
RNIterable_targetSdkVersion=31
4-
RNIterable_compileSdkVersion=31
5-
RNIterable_ndkversion=21.4.7075529
1+
RNIterable_kotlinVersion=2.0.21
2+
RNIterable_minSdkVersion=24
3+
RNIterable_targetSdkVersion=35
4+
RNIterable_compileSdkVersion=35
5+
RNIterable_ndkversion=27.1.12297006
66
android.useAndroidX=true
7-
android.enableJetifier=true
7+
android.enableJetifier=true

android/src/main/java/com/iterable/reactnative/RNIterableAPIModuleImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@
1212
import com.facebook.react.bridge.Arguments;
1313
import com.facebook.react.bridge.Callback;
1414
import com.facebook.react.bridge.ReactApplicationContext;
15-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
16-
import com.facebook.react.bridge.ReactMethod;
1715
import com.facebook.react.bridge.ReadableArray;
1816
import com.facebook.react.bridge.ReadableMap;
1917
import com.facebook.react.bridge.UiThreadUtil;
2018
import com.facebook.react.bridge.WritableMap;
21-
import com.facebook.react.module.annotations.ReactModule;
2219
import com.facebook.react.modules.core.DeviceEventManagerModule;
23-
import com.facebook.react.modules.core.RCTNativeAppEventEmitter;
2420

2521
import com.iterable.iterableapi.InboxSessionManager;
2622
import com.iterable.iterableapi.IterableAction;
@@ -40,7 +36,6 @@
4036
import com.iterable.iterableapi.IterableLogger;
4137
import com.iterable.iterableapi.IterableUrlHandler;
4238
import com.iterable.iterableapi.RNIterableInternal;
43-
import com.iterable.reactnative.Serialization;
4439

4540
import org.json.JSONArray;
4641
import org.json.JSONException;
Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
package com.iterable.reactnative;
22

3-
import java.util.ArrayList;
4-
import java.util.Arrays;
5-
import java.util.Collections;
6-
import java.util.List;
3+
import java.util.HashMap;
4+
import java.util.Map;
75

8-
import com.facebook.react.ReactPackage;
6+
import androidx.annotation.NonNull;
7+
import androidx.annotation.Nullable;
8+
import com.facebook.react.BaseReactPackage;
99
import com.facebook.react.bridge.NativeModule;
1010
import com.facebook.react.bridge.ReactApplicationContext;
11-
import com.facebook.react.uimanager.ViewManager;
12-
import com.facebook.react.bridge.JavaScriptModule;
11+
import com.facebook.react.module.model.ReactModuleInfo;
12+
import com.facebook.react.module.model.ReactModuleInfoProvider;
1313

14-
public class RNIterableAPIPackage implements ReactPackage {
14+
public class RNIterableAPIPackage extends BaseReactPackage {
15+
@Nullable
1516
@Override
16-
public List<NativeModule> createNativeModules(
17-
ReactApplicationContext reactContext) {
18-
List<NativeModule> modules = new ArrayList<>();
19-
20-
modules.add(new RNIterableAPIModule(reactContext));
21-
22-
return modules;
17+
public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
18+
if (RNIterableAPIModuleImpl.NAME.equals(name)) {
19+
return new RNIterableAPIModule(reactContext);
20+
} else {
21+
return null;
22+
}
2323
}
2424

25+
@NonNull
2526
@Override
26-
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
27-
return Collections.emptyList();
27+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
28+
return new ReactModuleInfoProvider() {
29+
@NonNull
30+
@Override
31+
public Map<String, ReactModuleInfo> getReactModuleInfos() {
32+
Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
33+
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
34+
moduleInfos.put(RNIterableAPIModuleImpl.NAME, new ReactModuleInfo(
35+
RNIterableAPIModuleImpl.NAME,
36+
RNIterableAPIModuleImpl.NAME,
37+
false, // canOverrideExistingModule
38+
false, // needsEagerInit
39+
false, // isCxxModule
40+
isTurboModule // isTurboModule
41+
));
42+
return moduleInfos;
43+
}
44+
};
2845
}
2946
}

0 commit comments

Comments
 (0)