Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit d94a035

Browse files
author
TeleGhost Dev
committed
Fix Android build: increase API level to 24 for getifaddrs and patch headers
1 parent 0919630 commit d94a035

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎scripts/build_i2pd_android.sh‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ if [ ! -f "$BUILD_DIR/.boost_patched" ]; then
4343
fi
4444
fi
4545

46+
# Patch i2pd source for getifaddrs on Android API < 24
47+
if [ ! -f "$BUILD_DIR/.i2pd_patched" ]; then
48+
echo "Patching i2pd source for getifaddrs compatibility..."
49+
# getifaddrs is available since API 24. For API 21, we need to use PurpleI2P's internal ifaddrs or a shim.
50+
# In util.cpp, we can force the use of PurpleI2P's internal ifaddrs.h
51+
sed -i 's/#include <ifaddrs.h>/#include "ifaddrs.h"/g' "$I2PD_SRC/libi2pd/util.cpp"
52+
# Ensure getifaddrs/freeifaddrs are prefixed with :: if needed, or just ensure the header is found.
53+
# Actually, the error is 'undeclared identifier'.
54+
# Let's just increase the API level to 24 in CMake as it's the standard way for modern NDKs.
55+
touch "$BUILD_DIR/.i2pd_patched"
56+
fi
57+
4658
# Loop over architectures
4759
for i in "${!ARCHS[@]}"; do
4860
ARCH=${ARCHS[$i]}
@@ -116,7 +128,7 @@ for i in "${!ARCHS[@]}"; do
116128
cmake -B "$ARCH_BUILD_DIR" -S "$I2PD_SRC/build" \
117129
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
118130
-DANDROID_ABI="$ABI" \
119-
-DANDROID_PLATFORM=android-21 \
131+
-DANDROID_PLATFORM=android-24 \
120132
-DWITH_UPNP=NO \
121133
-DBUILD_SHARED_LIBS=OFF \
122134
-DWITH_LIBRARY=ON \

0 commit comments

Comments
 (0)