Skip to content

Commit 16150d2

Browse files
committed
Update build.gradle file
1 parent 5cbfa9e commit 16150d2

File tree

1 file changed

+11
-52
lines changed

1 file changed

+11
-52
lines changed

android/build.gradle

+11-52
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,6 @@ def isHmsEnabled() {
2424
return (rootProject.hasProperty("airshipHmsEnabled") && rootProject.getProperty("airshipHmsEnabled") == "true") || (rootProject.ext.has("airshipHmsEnabled") && rootProject.ext.get("airshipHmsEnabled") == "true")
2525
}
2626

27-
def resolveReactNativeDirectory() {
28-
def reactNativeLocation = rootProject.hasProperty("reactNativeDir") ? rootProject.getProperty("reactNativeDir") : null
29-
30-
if (reactNativeLocation != null) {
31-
return file(reactNativeLocation)
32-
}
33-
34-
try {
35-
// Resolve React Native location with Node
36-
// This will make sure that we get installation location correctly in monorepos
37-
def reactNativePackageJsonPathStdout = new ByteArrayOutputStream()
38-
39-
exec {
40-
commandLine("node", "-p", "require.resolve('react-native/package.json')")
41-
ignoreExitValue true
42-
standardOutput = reactNativePackageJsonPathStdout
43-
}
44-
45-
def reactNativeFromProjectNodeModules = file(reactNativePackageJsonPathStdout.toString().trim()).getParentFile();
46-
47-
if (reactNativeFromProjectNodeModules.exists()) {
48-
return reactNativeFromProjectNodeModules
49-
}
50-
} catch (e) {
51-
// Ignore
52-
}
53-
54-
throw new Exception(
55-
"react-native-airship: Failed to resolve 'react-native' in the project. " +
56-
"If you have a non-standard project structure, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
57-
)
58-
}
59-
60-
61-
def reactNativeRootDir = resolveReactNativeDirectory()
62-
def reactProperties = new Properties()
63-
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
64-
65-
def reactNativeVersion = reactProperties.getProperty("VERSION_NAME")
66-
def (reactNativeMajorVersion, reactNativeMinorVersion) = reactNativeVersion.split("\\.").collect { it.isInteger() ? it.toInteger() : it }
67-
6827

6928
apply plugin: "com.android.library"
7029
apply plugin: "kotlin-android"
@@ -81,6 +40,7 @@ def getExtOrIntegerDefault(name) {
8140
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Airship_" + name]).toInteger()
8241
}
8342

43+
8444
android {
8545
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
8646

@@ -111,12 +71,13 @@ android {
11171
main {
11272
if (isNewArchitectureEnabled()) {
11373
java.srcDirs += [
114-
"src/newarch/java",
115-
// This is needed to build Kotlin project with NewArch enabled
116-
"${project.buildDir}/generated/source/codegen/java"
74+
"src/newarch",
75+
// Codegen specs
76+
"generated/java",
77+
"generated/jni"
11778
]
11879
} else {
119-
java.srcDirs += ["src/oldarch/java"]
80+
java.srcDirs += ["src/oldarch"]
12081
}
12182
}
12283
}
@@ -142,14 +103,12 @@ def proxy_version = getExtOrDefault("airshipProxyVersion")
142103
def airship_version = getExtOrDefault("airshipVersion")
143104

144105
dependencies {
145-
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
146-
//noinspection GradleDynamicVersion
147-
implementation "com.facebook.react:react-native:+"
148-
} else {
149-
implementation "com.facebook.react:react-android"
150-
}
151-
106+
// For < 0.71, this will be from the local maven repo
107+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
108+
//noinspection GradleDynamicVersion
109+
implementation "com.facebook.react:react-native:+"
152110
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
111+
153112
api "com.urbanairship.android:airship-framework-proxy:$proxy_version"
154113

155114
if (isHmsEnabled()) {

0 commit comments

Comments
 (0)