Skip to content

Commit f5e67e5

Browse files
authored
Improve "release:android" command (#130)
Improve yarn sample release:android
1 parent 46595e7 commit f5e67e5

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ local.properties
3636
.cxx/
3737
*.keystore
3838
!debug.keystore
39+
upload-keystore.jks
3940

4041
# node.js
4142
#

sample/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ android {
8080
checkDependencies false
8181
}
8282
tasks.whenTaskAdded { task ->
83-
if (task.name == 'lintAnalyzeDebug') {
83+
if (task.name == 'lintAnalyzeDebug' || task.name == 'generateReleaseLintVitalReportModel') {
8484
task.dependsOn 'copyReactNativeVectorIconFonts'
8585
}
8686
}

sample/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"clean": "rm -rf node_modules ios/build ios/pods vendor",
88
"clean:android": "(cd android && ./gradlew clean)",
99
"build:android": "sh ./scripts/build_android",
10+
"release:android": "sh ./scripts/release_android",
1011
"build:ios": "sh ./scripts/build_ios",
1112
"lint": "yarn typecheck && eslint .",
1213
"ios": "react-native run-ios --simulator 'iPhone 15 Pro'",

sample/scripts/release_android

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
11
#!/usr/bin/env bash
22

3-
set -ex
3+
# Working directory is "sample" when running "yarn sample release:android" from root.
44

5-
cd sample
5+
# Exit immediately if a command exits with a non-zero status
6+
set -e
7+
8+
# Print each command as it is executed
9+
set -x
610

711
mkdir -p android/app/src/main/assets
812
npx react-native bundle --platform android \
913
--dev false \
1014
--entry-file index.js \
1115
--bundle-output android/app/src/main/assets/index.android.bundle \
1216

17+
# Generate release build (.aab file)
1318
npx react-native build-android --mode=release
1419

15-
echo "Run \"cd sample && npx react-native run-android --variant=release\" to test the release build"
16-
echo "Output bundle location: sample/android/app/build/outputs/bundle/release/app-release.aab"
20+
# Generate APK (for testing)
21+
cd android
22+
./gradlew clean assembleRelease
23+
24+
# Stop printing commands
25+
set +x
26+
27+
cat << EOF
28+
29+
30+
Run "cd sample && npx react-native run-android --mode release" to test the release build.
31+
32+
Output files:
33+
- sample/android/app/build/outputs/bundle/release/app-release.aab (Upload to Play Store)
34+
- sample/android/app/build/outputs/apk/release/app-release.apk (For testing)
35+
36+
To install the release build:
37+
- Ensure an emulator or device is connected
38+
- Uninstall existing version: adb uninstall com.shopify.checkoutkitreactnative
39+
- Install new version: adb install android/app/build/outputs/apk/release/app-release.apk
40+
41+
To observe the production logs for your emulator/device:
42+
- Run "adb logcat"
43+
EOF

sample/src/App.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ function CatalogStack() {
172172
<Stack.Screen
173173
name="CatalogScreen"
174174
component={CatalogScreen}
175-
options={{headerShown: true, headerTitle: 'Catalog'}}
175+
options={{
176+
headerShown: true,
177+
headerTitle: __DEV__ ? 'Development' : 'Production',
178+
}}
176179
/>
177180
<Stack.Screen
178181
name="ProductDetails"

0 commit comments

Comments
 (0)