fix(android): local dev + wip

This commit is contained in:
devthejo 2025-10-01 11:41:08 +02:00
parent 0d0e694e8d
commit fd6ba1caab
No known key found for this signature in database
GPG key ID: 00CCA7A92B1D5351
9 changed files with 147 additions and 34 deletions

View file

@ -83,15 +83,26 @@ android {
applicationId 'com.alertesecours' applicationId 'com.alertesecours'
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
ndk {
abiFilters "arm64-v8a"
}
versionCode 220 versionCode 220
versionName "1.13.8" versionName "1.13.8"
multiDexEnabled true multiDexEnabled true
testBuildType System.getProperty('testBuildType', 'debug') testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
// Define ABI flavors so we can install the right dev client on emulator vs device.
flavorDimensions 'abi'
productFlavors {
deviceArm64 {
dimension 'abi'
ndk { abiFilters 'arm64-v8a' }
}
emulatorX86_64 {
dimension 'abi'
ndk { abiFilters 'x86_64' }
}
}
signingConfigs { signingConfigs {
debug { debug {
storeFile file('debug.keystore') storeFile file('debug.keystore')

View file

@ -29,7 +29,7 @@ android.enablePngCrunchInReleaseBuilds=true
# Use this property to specify which architecture you want to build. # Use this property to specify which architecture you want to build.
# You can also override it from the CLI using # You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64 # ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86_64
# Use this property to enable support to the new architecture. # Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in # This will allow you to use TurboModules and the Fabric render in

View file

@ -1,5 +1,4 @@
// debug // debug
import "./wdyr"; // <--- first import
import "./warnFilter"; import "./warnFilter";
import "expo-splash-screen"; import "expo-splash-screen";

View file

@ -180,7 +180,8 @@
F3F5A8D7A73545D78A4D8467 /* Fix Xcode 15 Bug */, F3F5A8D7A73545D78A4D8467 /* Fix Xcode 15 Bug */,
BC7FCBEF8C354C749AB11067 /* Fix Xcode 15 Bug */, BC7FCBEF8C354C749AB11067 /* Fix Xcode 15 Bug */,
59A6E29E61A94EC98E5B50A7 /* Fix Xcode 15 Bug */, 59A6E29E61A94EC98E5B50A7 /* Fix Xcode 15 Bug */,
822458BA69944A72BCDBEB3B /* Remove signature files (Xcode workaround) */, 07BB91F001704B368647D86B /* Fix Xcode 15 Bug */,
DD1558A5827A42DCA5A17C1F /* Remove signature files (Xcode workaround) */,
); );
buildRules = ( buildRules = (
); );
@ -1171,6 +1172,40 @@ fi";
shellScript = " shellScript = "
echo \"Remove signature files (Xcode workaround)\"; echo \"Remove signature files (Xcode workaround)\";
rm -rf \"$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature\"; rm -rf \"$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature\";
";
};
07BB91F001704B368647D86B /* Fix Xcode 15 Bug */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
name = "Fix Xcode 15 Bug";
inputPaths = (
);
outputPaths = (
);
shellPath = /bin/sh;
shellScript = "if [ \"$XCODE_VERSION_MAJOR\" = \"1500\" ]; then
echo \"Remove signature files (Xcode 15 workaround)\"
find \"$BUILD_DIR/${CONFIGURATION}-iphoneos\" -name \"*.signature\" -type f | xargs -r rm
fi";
};
DD1558A5827A42DCA5A17C1F /* Remove signature files (Xcode workaround) */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
name = "Remove signature files (Xcode workaround)";
inputPaths = (
);
outputPaths = (
);
shellPath = /bin/sh;
shellScript = "
echo \"Remove signature files (Xcode workaround)\";
rm -rf \"$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature\";
"; ";
}; };
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */

View file

@ -1,6 +1,7 @@
const { getDefaultConfig: getExpoDefaultConfig } = require("expo/metro-config"); const { getDefaultConfig: getExpoDefaultConfig } = require("expo/metro-config");
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config"); const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
const { getSentryExpoConfig } = require("@sentry/react-native/metro"); const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const exclusionList = require("metro-config/src/defaults/exclusionList");
const defaultConfig = getDefaultConfig(__dirname); const defaultConfig = getDefaultConfig(__dirname);
const sentryConfig = getSentryExpoConfig(__dirname); const sentryConfig = getSentryExpoConfig(__dirname);
@ -9,6 +10,10 @@ const sentryConfig = getSentryExpoConfig(__dirname);
const config = { const config = {
resolver: { resolver: {
...sentryConfig.resolver, ...sentryConfig.resolver,
// Ignore transient JNI output folders to prevent ENOENT watchers on missing ABI directories
blockList: exclusionList([
/node_modules\/.*\/android\/build\/intermediates\/(library_jni|merged_jni_libs)\/.*/,
]),
sourceExts: [...sentryConfig.resolver.sourceExts, "cjs"], sourceExts: [...sentryConfig.resolver.sourceExts, "cjs"],
assetExts: [...defaultConfig.resolver.assetExts, "ttf"], assetExts: [...defaultConfig.resolver.assetExts, "ttf"],
}, },

View file

@ -6,8 +6,8 @@
"start": "expo start --dev-client --private-key-path ./keys/private-key.pem", "start": "expo start --dev-client --private-key-path ./keys/private-key.pem",
"start:staging": "dotenv --override -e .env.staging -- yarn start", "start:staging": "dotenv --override -e .env.staging -- yarn start",
"start:prod": "dotenv --override -e .env.prod -- yarn start", "start:prod": "dotenv --override -e .env.prod -- yarn start",
"android": "expo run:android", "android": "scripts/android-run.sh",
"android:staging": "dotenv --override -e .env.staging -- expo run:android", "android:staging": "dotenv --override -e .env.staging -- bash -lc 'EMU=$(adb devices | awk \"/^emulator-/{print $1}\" | head -n1); USB=$(adb devices -l | awk \"/ device usb:/{print $1}\" | head -n1); if [ -n \"$EMU\" ] && [ -z \"$USB\" ]; then EXPO_ANDROID_GRADLE_ARGS=\"-PreactNativeArchitectures=x86_64\" exec expo run:android --variant emulatorX86_64Debug; elif [ -n \"$USB\" ] && [ -z \"$EMU\" ]; then EXPO_ANDROID_GRADLE_ARGS=\"-PreactNativeArchitectures=arm64-v8a\" exec expo run:android --variant deviceArm64Debug; else echo \"Connect exactly one target (emulator or USB). Or run: EXPO_ANDROID_GRADLE_ARGS=\\\"-PreactNativeArchitectures=x86_64\\\" expo run:android --variant emulatorX86_64Debug | EXPO_ANDROID_GRADLE_ARGS=\\\"-PreactNativeArchitectures=arm64-v8a\\\" expo run:android --variant deviceArm64Debug\"; exit 1; fi'",
"android:prod": "dotenv --override -e .env.prod -- expo run:android", "android:prod": "dotenv --override -e .env.prod -- expo run:android",
"bundle:android": "dotenv --override -e .env.prod -- bundle-android", "bundle:android": "dotenv --override -e .env.prod -- bundle-android",
"bundle:android:fastdev": "SENTRY_ALLOW_FAILURE=true SENTRY_AUTH_TOKEN='' yarn bundle:android", "bundle:android:fastdev": "SENTRY_ALLOW_FAILURE=true SENTRY_AUTH_TOKEN='' yarn bundle:android",
@ -228,7 +228,6 @@
"@types/lodash.debounce": "^4", "@types/lodash.debounce": "^4",
"@types/lodash.kebabcase": "^4", "@types/lodash.kebabcase": "^4",
"@types/lodash.snakecase": "^4", "@types/lodash.snakecase": "^4",
"@welldone-software/why-did-you-render": "^8.0.1",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-plugin-module-resolver": "^5.0.0", "babel-plugin-module-resolver": "^5.0.0",
"babel-plugin-root-import": "^6.6.0", "babel-plugin-root-import": "^6.6.0",

86
scripts/android-run.sh Executable file
View file

@ -0,0 +1,86 @@
#!/usr/bin/env bash
# Smart android runner for Expo dev client with ABI flavors.
# DEVICE env var selects the target explicitly (no autodetect).
# - If DEVICE equals "emulator" or starts with "emulator-" => emulator (x86_64)
# - Otherwise => USB device (arm64-v8a)
#
# Examples:
# DEVICE=emulator-5554 yarn android
# DEVICE=emulator yarn android
# DEVICE=45290DLAQ000DG yarn android
# DEVICE=device yarn android # (will not set ANDROID_SERIAL)
#
# Overrides:
# EXPO_ANDROID_GRADLE_ARGS # pass additional Gradle args (preserves ABI defaults)
# EXTRA_ARGS # extra args forwarded to `expo run:android`
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
if ! command -v adb >/dev/null 2>&1; then
echo "adb not found in PATH. Please install Android platform-tools." >&2
exit 1
fi
if [[ -z "${DEVICE:-}" ]]; then
cat >&2 <<EOF
DEVICE environment variable is required (no autodetect).
Usage examples:
DEVICE=emulator-5554 yarn android
DEVICE=emulator yarn android
DEVICE=45290DLAQ000DG yarn android
DEVICE=device yarn android
Tip: set DEVICE to a serial (e.g., emulator-5554 or a USB serial) to also export ANDROID_SERIAL
so Gradle/adb target that device explicitly when multiple devices are connected.
EOF
exit 1
fi
EXTRA_ARGS="${EXTRA_ARGS:-}"
LOWER_DEVICE="$(echo "$DEVICE" | tr '[:upper:]' '[:lower:]')"
# Determine target kind
if [[ "$LOWER_DEVICE" == "emulator" || "$DEVICE" =~ ^emulator- ]]; then
TARGET_KIND="emulator"
else
TARGET_KIND="device"
fi
# If DEVICE looks like an adb serial (not the generic tokens), export ANDROID_SERIAL
if [[ "$LOWER_DEVICE" != "emulator" && "$LOWER_DEVICE" != "device" ]]; then
export ANDROID_SERIAL="$DEVICE"
fi
# Ensure expo CLI is available
if ! command -v expo >/dev/null 2>&1; then
echo "expo CLI not found. Using npx expo ..." >&2
USE_NPX=1
else
USE_NPX=0
fi
if [[ "$TARGET_KIND" == "emulator" ]]; then
# x86_64 ABI for emulator
export EXPO_ANDROID_GRADLE_ARGS="${EXPO_ANDROID_GRADLE_ARGS:- -PreactNativeArchitectures=x86_64}"
echo "Target: Emulator (DEVICE=${DEVICE})"
echo "Gradle args: ${EXPO_ANDROID_GRADLE_ARGS}"
echo "Variant : emulatorX86_64Debug"
if [[ "$USE_NPX" -eq 1 ]]; then
exec npx expo run:android --variant emulatorX86_64Debug ${EXTRA_ARGS}
else
exec expo run:android --variant emulatorX86_64Debug ${EXTRA_ARGS}
fi
fi
# USB device (arm64-v8a)
export EXPO_ANDROID_GRADLE_ARGS="${EXPO_ANDROID_GRADLE_ARGS:- -PreactNativeArchitectures=arm64-v8a}"
echo "Target: USB Device (DEVICE=${DEVICE})"
echo "Gradle args: ${EXPO_ANDROID_GRADLE_ARGS}"
echo "Variant : deviceArm64Debug"
if [[ "$USE_NPX" -eq 1 ]]; then
exec npx expo run:android --variant deviceArm64Debug ${EXTRA_ARGS}
else
exec expo run:android --variant deviceArm64Debug ${EXTRA_ARGS}
fi

10
wdyr.js
View file

@ -1,10 +0,0 @@
import React from "react";
if (process.env.NODE_ENV === "development") {
const whyDidYouRender = require("@welldone-software/why-did-you-render");
whyDidYouRender(React, {
// trackAllPureComponents: true,
// trackHooks: true,
// logOnDifferentValues: true,
});
}

View file

@ -6765,17 +6765,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@welldone-software/why-did-you-render@npm:^8.0.1":
version: 8.0.1
resolution: "@welldone-software/why-did-you-render@npm:8.0.1"
dependencies:
lodash: "npm:^4"
peerDependencies:
react: ^18
checksum: 10/bfa9ad79bd61d6d003733f21842eb79eda33f19354aed85a6bec860ace51d7276aff52a0947a982c00e992baef94b8c4dc63545713d5df72a7d014adaa74cc99
languageName: node
linkType: hard
"@wry/caches@npm:^1.0.0": "@wry/caches@npm:^1.0.0":
version: 1.0.1 version: 1.0.1
resolution: "@wry/caches@npm:1.0.1" resolution: "@wry/caches@npm:1.0.1"
@ -7076,7 +7065,6 @@ __metadata:
"@types/lodash.kebabcase": "npm:^4" "@types/lodash.kebabcase": "npm:^4"
"@types/lodash.snakecase": "npm:^4" "@types/lodash.snakecase": "npm:^4"
"@types/react": "npm:~19.0.10" "@types/react": "npm:~19.0.10"
"@welldone-software/why-did-you-render": "npm:^8.0.1"
ajv: "npm:^8.12.0" ajv: "npm:^8.12.0"
ajv-errors: "npm:^3.0.0" ajv-errors: "npm:^3.0.0"
ajv-formats: "npm:^2.1.1" ajv-formats: "npm:^2.1.1"
@ -14232,7 +14220,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"lodash@npm:^4, lodash@npm:^4.17.11, lodash@npm:^4.17.15, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:^4.3.0": "lodash@npm:^4.17.11, lodash@npm:^4.17.15, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:^4.3.0":
version: 4.17.21 version: 4.17.21
resolution: "lodash@npm:4.17.21" resolution: "lodash@npm:4.17.21"
checksum: 10/c08619c038846ea6ac754abd6dd29d2568aa705feb69339e836dfa8d8b09abbb2f859371e86863eda41848221f9af43714491467b5b0299122431e202bb0c532 checksum: 10/c08619c038846ea6ac754abd6dd29d2568aa705feb69339e836dfa8d8b09abbb2f859371e86863eda41848221f9af43714491467b5b0299122431e202bb0c532