Skip to content

Commit 00cc8e1

Browse files
fix: added version check for new arch
1 parent 2d98755 commit 00cc8e1

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

android/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,18 @@ def rnVersion = getRNVersion()
6363
println "Found react native version as ${rnVersion}"
6464

6565
def isNewArchitectureEnabled() {
66-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
66+
if (rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true") {
67+
return true
68+
}
69+
70+
def version = rnVersion.replaceAll(/[^0-9.]/, "")
71+
def parts = version.tokenize('.')
72+
if (parts.size() < 2) {
73+
return false
74+
}
75+
def major = parts[0] as int
76+
def minor = parts[1] as int
77+
return (major > 0) || (major == 0 && minor >= 82)
6778
}
6879

6980
apply plugin: 'com.android.library'

example/android/app/src/main/java/in/juspay/hypersdkreact/example/MainApplication.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,21 @@ protected String getJSMainModuleName() {
4747

4848
@Override
4949
protected boolean isNewArchEnabled() {
50-
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
50+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
51+
return true;
52+
}
53+
54+
String version = BuildConfig.REACT_NATIVE_VERSION;
55+
String[] parts = version.split("\\.");
56+
57+
if (parts.length < 2) {
58+
return false;
59+
}
60+
61+
int major = Integer.parseInt(parts[0]);
62+
int minor = Integer.parseInt(parts[1]);
63+
64+
return major > 0 || (major == 0 && minor >= 82);
5165
}
5266

5367
@Override

0 commit comments

Comments
 (0)