Skip to content

Commit 46b60ab

Browse files
misc: Add easy enabled splits and flavors in RN Android samples (#4157)
1 parent ba46d3f commit 46b60ab

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

samples/react-native/android/app/build.gradle

+33
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,39 @@ android {
146146
keyPassword 'android'
147147
}
148148
}
149+
150+
if (System.getenv('SENTRY_SAMPLE_ENABLE_ABI_SPLIT') == 'true') {
151+
splits {
152+
abi {
153+
enable true
154+
reset()
155+
include 'x86', 'arm64-v8a'
156+
universalApk true
157+
}
158+
}
159+
project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
160+
android.applicationVariants.all { variant ->
161+
variant.outputs.each { output ->
162+
output.versionCodeOverride =
163+
project.ext.versionCodes.get(output.getFilter(
164+
com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode
165+
}
166+
}
167+
}
168+
169+
if (System.getenv('SENTRY_SAMPLE_ENABLE_FLAVORS') == 'true') {
170+
flavorDimensions "version"
171+
productFlavors {
172+
regular {
173+
dimension "version"
174+
}
175+
demo {
176+
dimension "version"
177+
applicationIdSuffix "demo"
178+
}
179+
}
180+
}
181+
149182
buildTypes {
150183
debug {
151184
signingConfig signingConfigs.debug

samples/react-native/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"clean-watchman": "watchman watch-del-all",
1818
"set-build-number": "npx react-native-version --skip-tag --never-amend --set-build",
1919
"set-version": "npm version --no-git-tag-version",
20-
"postversion": "npx react-native-version --skip-tag --never-amend"
20+
"postversion": "npx react-native-version --skip-tag --never-amend",
21+
"build-android-release-splits-flavors": "export SENTRY_SAMPLE_ENABLE_ABI_SPLIT=true; export SENTRY_SAMPLE_ENABLE_FLAVORS=true; cd android; ./gradlew assembleRelease; cd .."
2122
},
2223
"dependencies": {
2324
"@react-navigation/bottom-tabs": "^6.5.12",

0 commit comments

Comments
 (0)