From 46b60abf2a15521db82890ffba94d955f560c92a Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:08:05 +0200 Subject: [PATCH] misc: Add easy enabled splits and flavors in RN Android samples (#4157) --- samples/react-native/android/app/build.gradle | 33 +++++++++++++++++++ samples/react-native/package.json | 3 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/samples/react-native/android/app/build.gradle b/samples/react-native/android/app/build.gradle index bc7b484bb..2cde7445c 100644 --- a/samples/react-native/android/app/build.gradle +++ b/samples/react-native/android/app/build.gradle @@ -146,6 +146,39 @@ android { keyPassword 'android' } } + + if (System.getenv('SENTRY_SAMPLE_ENABLE_ABI_SPLIT') == 'true') { + splits { + abi { + enable true + reset() + include 'x86', 'arm64-v8a' + universalApk true + } + } + project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9] + android.applicationVariants.all { variant -> + variant.outputs.each { output -> + output.versionCodeOverride = + project.ext.versionCodes.get(output.getFilter( + com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode + } + } + } + + if (System.getenv('SENTRY_SAMPLE_ENABLE_FLAVORS') == 'true') { + flavorDimensions "version" + productFlavors { + regular { + dimension "version" + } + demo { + dimension "version" + applicationIdSuffix "demo" + } + } + } + buildTypes { debug { signingConfig signingConfigs.debug diff --git a/samples/react-native/package.json b/samples/react-native/package.json index a4567bcac..53c0d28f6 100644 --- a/samples/react-native/package.json +++ b/samples/react-native/package.json @@ -17,7 +17,8 @@ "clean-watchman": "watchman watch-del-all", "set-build-number": "npx react-native-version --skip-tag --never-amend --set-build", "set-version": "npm version --no-git-tag-version", - "postversion": "npx react-native-version --skip-tag --never-amend" + "postversion": "npx react-native-version --skip-tag --never-amend", + "build-android-release-splits-flavors": "export SENTRY_SAMPLE_ENABLE_ABI_SPLIT=true; export SENTRY_SAMPLE_ENABLE_FLAVORS=true; cd android; ./gradlew assembleRelease; cd .." }, "dependencies": { "@react-navigation/bottom-tabs": "^6.5.12",