Skip to content

Commit 8793c23

Browse files
16kb alignment of Android SDK (#51)
* chore: update version to 5.2.0 in pubspec.yaml * chore: update README with development instructions, add mavenLocal() to build.gradle files, and update dependencies in pubspec.lock * chore: update Podfile.lock and project settings to support iOS 13.0 * version-bump: gw-4.4.1, loans-3.1.1 * clean: removed .dart_tool, .gradle files * Delete android/.gradle/nb-cache * Delete smart_investing/pubspec.lock * update: comment-resolve for SI-pubspec.lock
1 parent e0b961e commit 8793c23

10 files changed

Lines changed: 224 additions & 11 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,28 @@ To deploy a new version of the package:
3737

3838
5. **Run the publish workflow**
3939
Go to [GitHub Actions](https://github.com/smallcase/gw-mob-sdk-flutter/actions) and manually trigger the "🚀 Publish" workflow on the created tag. The workflow will not work on branches - it must be run on a tag.
40+
41+
## Development
42+
43+
### Reset (clean + reinstall deps)
44+
45+
Use the reset script to clean build artifacts (Flutter, Gradle, CocoaPods), lock files and reinstall dependencies across all packages (`scgateway`, `loans`, `smart_investing`):
46+
47+
```bash
48+
bash scripts/reset.sh
49+
```
50+
51+
Then run the example app:
52+
53+
```bash
54+
cd smart_investing && flutter run
55+
```
56+
57+
### Check ELF 16KB alignment in an APK
58+
59+
Build the APK, then run the checker (requires `zipalign`, `objdump` in PATH):
60+
61+
```bash
62+
cd smart_investing && flutter build apk --release
63+
bash scripts/check_elf_alignment.sh smart_investing/build/app/outputs/flutter-apk/app-release.apk
64+
```

loans/android/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ buildscript {
1515

1616
rootProject.allprojects {
1717
repositories {
18+
mavenLocal()
1819
maven {
1920
url "https://artifactory.smallcase.com/artifactory/gradle-dev-local"
2021
credentials {
@@ -64,5 +65,5 @@ android {
6465

6566
dependencies {
6667
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
67-
implementation "com.smallcase.loans:sdk:3.1.1"
68+
implementation 'com.smallcase.loans:sdk:3.1.1'
6869
}

scgateway/android/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version '1.0-SNAPSHOT'
33

44
buildscript {
55
repositories {
6+
mavenLocal()
67
google()
78
jcenter()
89
}
@@ -15,6 +16,7 @@ buildscript {
1516

1617
rootProject.allprojects {
1718
repositories {
19+
mavenLocal()
1820
maven {
1921
url "https://artifactory.smallcase.com/artifactory/gradle-dev-local"
2022
credentials {
@@ -64,6 +66,5 @@ android {
6466

6567
dependencies {
6668
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
67-
68-
implementation "com.smallcase.gateway:sdk:4.4.0"
69+
implementation 'com.smallcase.gateway:sdk:4.4.1'
6970
}

scripts/check_elf_alignment.sh

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/bin/bash
2+
progname="${0##*/}"
3+
progname="${progname%.sh}"
4+
5+
# usage: check_elf_alignment.sh [path to *.so files|path to *.apk|path to *.apex]
6+
7+
cleanup_trap() {
8+
if [ -n "${tmp:-}" -a -d "${tmp:-}" ]; then
9+
rm -rf ${tmp}
10+
fi
11+
exit $1
12+
}
13+
14+
usage() {
15+
echo "Host side script to check the ELF alignment of shared libraries."
16+
echo "Shared libraries are reported ALIGNED when their ELF regions are"
17+
echo "16 KB or 64 KB aligned. Otherwise they are reported as UNALIGNED."
18+
echo
19+
echo "Usage: ${progname} [input-path|input-APK|input-APEX]"
20+
}
21+
22+
if [ ${#} -ne 1 ]; then
23+
usage
24+
exit 1
25+
fi
26+
27+
case ${1} in
28+
--help | -h | -\?)
29+
usage
30+
exit 0
31+
;;
32+
33+
*)
34+
dir="${1}"
35+
;;
36+
esac
37+
38+
if ! [ -f "${dir}" -o -d "${dir}" ]; then
39+
echo "Invalid file: ${dir}" >&2
40+
exit 1
41+
fi
42+
43+
if [[ "${dir}" == *.apk ]]; then
44+
trap 'cleanup_trap 0' EXIT
45+
46+
echo
47+
echo "Recursively analyzing $dir"
48+
echo
49+
50+
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
51+
echo "=== APK zip-alignment ==="
52+
zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
53+
echo "========================="
54+
else
55+
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
56+
echo " You can install the latest build-tools by running the below command"
57+
echo " and updating your $PATH:"
58+
echo
59+
echo " sdkmanager \"build-tools;35.0.0-rc3\""
60+
fi
61+
62+
dir_filename=$(basename "${dir}")
63+
tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
64+
unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
65+
dir="${tmp}"
66+
fi
67+
68+
if [[ "${dir}" == *.apex ]]; then
69+
trap 'cleanup_trap 0' EXIT
70+
71+
echo
72+
echo "Recursively analyzing $dir"
73+
echo
74+
75+
dir_filename=$(basename "${dir}")
76+
tmp=$(mktemp -d -t "${dir_filename%.apex}_out_XXXXX")
77+
deapexer extract "${dir}" "${tmp}" || { echo "Failed to deapex." && exit 1; }
78+
dir="${tmp}"
79+
fi
80+
81+
RED="\e[31m"
82+
GREEN="\e[32m"
83+
ENDCOLOR="\e[0m"
84+
85+
unaligned_libs=()
86+
87+
echo
88+
echo "=== ELF alignment ==="
89+
90+
matches="$(find "${dir}" -type f)"
91+
IFS=$'\n'
92+
for match in $matches; do
93+
[[ "${match}" == *".apk" ]] && echo "WARNING: doesn't recursively inspect .apk file: ${match}"
94+
[[ "${match}" == *".apex" ]] && echo "WARNING: doesn't recursively inspect .apex file: ${match}"
95+
96+
[[ $(file "${match}") == *"ELF"* ]] || continue
97+
98+
res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)"
99+
if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then
100+
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
101+
else
102+
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
103+
unaligned_libs+=("${match}")
104+
fi
105+
done
106+
107+
if [ ${#unaligned_libs[@]} -gt 0 ]; then
108+
echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
109+
elif [ -n "${dir_filename:-}" ]; then
110+
echo -e "ELF Verification Successful"
111+
fi
112+
echo "====================="
113+
114+

scripts/reset.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Resolve repo root (scripts/..)
6+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7+
8+
echo "Repo root: ${REPO_ROOT}"
9+
10+
clean_flutter_pkg() {
11+
local pkg_dir="$1"
12+
if [[ ! -d "${pkg_dir}" ]]; then
13+
return 0
14+
fi
15+
16+
echo "\n==> Cleaning ${pkg_dir}"
17+
18+
# Generic Flutter/Dart
19+
rm -rf "${pkg_dir}/build" \
20+
"${pkg_dir}/.dart_tool" \
21+
"${pkg_dir}/pubspec.lock" || true
22+
23+
# Android bits (delete only)
24+
if [[ -d "${pkg_dir}/android" ]]; then
25+
rm -rf "${pkg_dir}/android/build" \
26+
"${pkg_dir}/android/.gradle" \
27+
"${pkg_dir}/android/.cxx" || true
28+
fi
29+
30+
# iOS bits (delete only)
31+
if [[ -d "${pkg_dir}/ios" ]]; then
32+
rm -rf "${pkg_dir}/ios/Pods" \
33+
"${pkg_dir}/ios/Podfile.lock" \
34+
"${pkg_dir}/ios/.symlinks" \
35+
"${pkg_dir}/ios/Flutter/Flutter.podspec" \
36+
"${pkg_dir}/ios/Flutter/ephemeral" || true
37+
fi
38+
39+
# macOS bits (delete only)
40+
if [[ -d "${pkg_dir}/macos" ]]; then
41+
rm -rf "${pkg_dir}/macos/Pods" \
42+
"${pkg_dir}/macos/Podfile.lock" || true
43+
fi
44+
}
45+
46+
flutter_pub_get() {
47+
local pkg_dir="$1"
48+
if [[ -d "${pkg_dir}" ]]; then
49+
echo "\n==> Getting dependencies in ${pkg_dir}"
50+
(cd "${pkg_dir}" && flutter pub get)
51+
fi
52+
}
53+
54+
#!/usr/bin/env bash
55+
56+
# Packages in this monorepo
57+
SCGATEWAY_DIR="${REPO_ROOT}/scgateway"
58+
LOANS_DIR="${REPO_ROOT}/loans"
59+
SMART_INVESTING_DIR="${REPO_ROOT}/smart_investing"
60+
61+
echo "\n=== Cleaning packages ==="
62+
clean_flutter_pkg "${SCGATEWAY_DIR}"
63+
clean_flutter_pkg "${LOANS_DIR}"
64+
clean_flutter_pkg "${SMART_INVESTING_DIR}"
65+
66+
echo "\nDone. Next steps (run manually as needed):"
67+
echo " - cd scgateway && flutter pub get"
68+
echo " - cd loans && flutter pub get"
69+
echo " - cd smart_investing && flutter pub get && flutter run"
70+
71+

smart_investing/android/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
allprojects {
22
repositories {
3+
mavenLocal()
34
google()
45
mavenCentral()
56
}

smart_investing/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>12.0</string>
24+
<string>13.0</string>
2525
</dict>
2626
</plist>

smart_investing/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ EXTERNAL SOURCES:
3838
:path: ".symlinks/plugins/scloans/ios"
3939

4040
SPEC CHECKSUMS:
41-
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
41+
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
4242
Mixpanel-swift: 7b26468fc0e2e521104e51d65c4bbf7cab8162f8
4343
mixpanel_flutter: a0b6b937035899cd01951735ad5f87718b2ffee5
4444
SCGateway: f502f44122537b777861093ef97f67ccc311d4d0

smart_investing/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
97C146EC1CF9000F007C117D /* Resources */,
198198
9705A1C41CF9048500538489 /* Embed Frameworks */,
199199
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
200-
A65A22CF8499D3153DE3CB8F /* [CP] Embed Pods Frameworks */,
200+
B7D1B14AD0C99264C7FFD2EA /* [CP] Embed Pods Frameworks */,
201201
);
202202
buildRules = (
203203
);
@@ -322,7 +322,7 @@
322322
shellPath = /bin/sh;
323323
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
324324
};
325-
A65A22CF8499D3153DE3CB8F /* [CP] Embed Pods Frameworks */ = {
325+
B7D1B14AD0C99264C7FFD2EA /* [CP] Embed Pods Frameworks */ = {
326326
isa = PBXShellScriptBuildPhase;
327327
buildActionMask = 2147483647;
328328
files = (
@@ -454,7 +454,7 @@
454454
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
455455
GCC_WARN_UNUSED_FUNCTION = YES;
456456
GCC_WARN_UNUSED_VARIABLE = YES;
457-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
457+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
458458
MTL_ENABLE_DEBUG_INFO = NO;
459459
SDKROOT = iphoneos;
460460
SUPPORTED_PLATFORMS = iphoneos;
@@ -586,7 +586,7 @@
586586
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
587587
GCC_WARN_UNUSED_FUNCTION = YES;
588588
GCC_WARN_UNUSED_VARIABLE = YES;
589-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
589+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
590590
MTL_ENABLE_DEBUG_INFO = YES;
591591
ONLY_ACTIVE_ARCH = YES;
592592
SDKROOT = iphoneos;
@@ -637,7 +637,7 @@
637637
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
638638
GCC_WARN_UNUSED_FUNCTION = YES;
639639
GCC_WARN_UNUSED_VARIABLE = YES;
640-
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
640+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
641641
MTL_ENABLE_DEBUG_INFO = NO;
642642
SDKROOT = iphoneos;
643643
SUPPORTED_PLATFORMS = iphoneos;

smart_investing/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,4 +677,4 @@ packages:
677677
version: "3.1.3"
678678
sdks:
679679
dart: ">=3.8.1 <4.0.0"
680-
flutter: ">=3.18.0-18.0.pre.54"
680+
flutter: ">=3.18.0-18.0.pre.54"

0 commit comments

Comments
 (0)