Skip to content

Commit 3a1e95a

Browse files
committed
feat: Add Android build configuration and manifest files for new architecture support
1 parent 8c8e732 commit 3a1e95a

File tree

5 files changed

+103
-2
lines changed

5 files changed

+103
-2
lines changed

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ code-push-plugin-testing-framework/
3939

4040
# Android build artifacts and Android Studio bits
4141
android/build
42-
android/app/
4342
android/app/build
4443
android/local.properties
4544
android/.gradle

android/app/build.gradle

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import groovy.json.JsonSlurper
2+
3+
apply plugin: "com.android.library"
4+
5+
def safeExtGet(prop, fallback) {
6+
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
7+
}
8+
9+
def DEFAULT_COMPILE_SDK_VERSION = 26
10+
def DEFAULT_TARGET_SDK_VERSION = 26
11+
def DEFAULT_MIN_SDK_VERSION = 16
12+
13+
def findReactNativePackageJson() {
14+
File currentDir = projectDir
15+
16+
while (currentDir != null) {
17+
File packageJson = new File(currentDir, "node_modules/react-native/package.json")
18+
if (packageJson.exists()) {
19+
return packageJson
20+
}
21+
22+
currentDir = currentDir.parentFile
23+
}
24+
25+
return null
26+
}
27+
28+
def getReactNativeVersion() {
29+
File packageJson = findReactNativePackageJson()
30+
if (packageJson == null) {
31+
return null
32+
}
33+
34+
def version = new JsonSlurper().parseText(packageJson.text).version
35+
return version.tokenize("-")[0]
36+
}
37+
38+
def getReactNativeMinorVersion() {
39+
def reactNativeVersion = getReactNativeVersion()
40+
if (reactNativeVersion == null) {
41+
return null
42+
}
43+
44+
def versionParts = reactNativeVersion.tokenize(".")
45+
if (versionParts.size() < 2) {
46+
return null
47+
}
48+
49+
return versionParts[1].toInteger()
50+
}
51+
52+
def reactNativeVersion = getReactNativeVersion()
53+
def reactNativeMinorVersion = getReactNativeMinorVersion()
54+
def reactNativeDependency = reactNativeMinorVersion != null && reactNativeMinorVersion < 71
55+
? "com.facebook.react:react-native:${reactNativeVersion ?: '+'}"
56+
: "com.facebook.react:react-android:${reactNativeVersion ?: '+'}"
57+
58+
android {
59+
if (project.android.hasProperty("namespace")) {
60+
namespace "com.microsoft.codepush.react"
61+
}
62+
63+
compileSdkVersion safeExtGet("compileSdkVersion", DEFAULT_COMPILE_SDK_VERSION)
64+
65+
defaultConfig {
66+
minSdkVersion safeExtGet("minSdkVersion", DEFAULT_MIN_SDK_VERSION)
67+
targetSdkVersion safeExtGet("targetSdkVersion", DEFAULT_TARGET_SDK_VERSION)
68+
versionCode 1
69+
versionName "1.0"
70+
consumerProguardFiles "../proguard-rules.pro"
71+
}
72+
73+
sourceSets {
74+
main {
75+
java.srcDirs = ["../src/main/java"]
76+
}
77+
}
78+
79+
compileOptions {
80+
sourceCompatibility JavaVersion.VERSION_1_8
81+
targetCompatibility JavaVersion.VERSION_1_8
82+
}
83+
84+
lintOptions {
85+
abortOnError false
86+
}
87+
}
88+
89+
repositories {
90+
google()
91+
mavenCentral()
92+
mavenLocal()
93+
}
94+
95+
dependencies {
96+
implementation(reactNativeDependency)
97+
implementation "com.nimbusds:nimbus-jose-jwt:9.37.3"
98+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.INTERNET" />
3+
</manifest>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.microsoft.codepush.react" />

android/settings.gradle

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)