mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
android: support for ARMv7a and Android 8+ (#2038)
* add armv7a * disable armv6l, that is lacking SMP atomics * Add Android 8 setting (API Ver 26) * Drop x86_64-linux, this makes no sense with `pkgs' = androidPkgs`. * Drop mis-labled x86_64-linux:lib:support (it was aarch64-android) * Drop x86_64-android, these do not exist in nixpkgs The ones set up were aarch64-android anyway (pkgs' = androidPkgs) * android: support Android 8+, armeabi-v7a (32 bit) (#2012) * test * stubs for allowing to launch the app * more stubs and minSdk lowered to 26 * replaced functions that supported on higher API levels with other functions * animated images on lower API levels and write permission * updated abi filter and scripts for downloading libs * changed compression script for multiple apks * cmake changes --------- Co-authored-by: Avently <7953703+avently@users.noreply.github.com> * update haskell.nix ref * bump hackage * bump haskell.nix (again) * build-android: add armv7 * flake.nix: remove local nixconf This change to flake.nix breaks build-android.sh script by forcing user to input y/n. AFAIK, this cannot be automated and I rather not include workarounds like piping "yes n | nix build ...". * build-android.sh: update nix version * flake.{nix,lock}: testing * flake.{nix,lock}: restore to original * update android/prepare script to use zip archives * update gradle file * android: 4.6-beta.0 (104) * android: abi filter for bundle (#2075) * android: abi filter for bundle * removed log --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --------- Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com> Co-authored-by: Avently <7953703+avently@users.noreply.github.com> Co-authored-by: shum <shum@liber.li>
This commit is contained in:
committed by
GitHub
parent
b2aec6d6a7
commit
05c4a6c682
@@ -12,9 +12,9 @@ nix_install() {
|
||||
[ ! -d /nix ] && sudo sh -c "mkdir -p /nix && chown -R $u /nix"
|
||||
|
||||
# Install nix
|
||||
nix_ver="nix-2.11.1"
|
||||
nix_ver="nix-2.14.1"
|
||||
nix_url="https://releases.nixos.org/nix/$nix_ver/install"
|
||||
nix_hash="4569a01dc5f62056f29f3195673bc3242fc70bf2474927fb5d8549c4d997402d"
|
||||
nix_hash="565974057264f0536f600c68d59395927cd73e9fc5a60f33c1906e8f7bc33fcf"
|
||||
|
||||
curl -sSf "$nix_url" -o "$tmp/nix-install"
|
||||
printf "%s %s" "$nix_hash" "$tmp/nix-install" | sha256sum -c
|
||||
@@ -29,11 +29,16 @@ nix_setup() {
|
||||
}
|
||||
|
||||
git_setup() {
|
||||
[ "$folder" != "." ] && {
|
||||
git clone --depth=1 https://github.com/simplex-chat/simplex-chat "$folder"
|
||||
}
|
||||
|
||||
# Switch to nix-android branch
|
||||
git -C "$folder" checkout "$commit"
|
||||
|
||||
# Create missing folders
|
||||
mkdir -p "$folder/apps/android/app/src/main/cpp/libs/arm64-v8a"
|
||||
mkdir -p "$folder/apps/android/app/src/main/cpp/libs/armeabi-v7a"
|
||||
}
|
||||
|
||||
checks() {
|
||||
@@ -55,10 +60,6 @@ checks() {
|
||||
esac
|
||||
done
|
||||
|
||||
[ "$folder" != "." ] && {
|
||||
git clone https://github.com/simplex-chat/simplex-chat "$folder"
|
||||
}
|
||||
|
||||
if [ -n "$commands_failed" ]; then
|
||||
commands_failed=${commands_failed% *}
|
||||
printf "%s is not found in your \$PATH. Please install them and re-run the script.\n" "$commands_failed"
|
||||
@@ -72,21 +73,31 @@ build() {
|
||||
# Build simplex lib
|
||||
nix build "$folder#hydraJobs.aarch64-android:lib:simplex-chat.x86_64-linux"
|
||||
unzip -o "$PWD/result/pkg-aarch64-android-libsimplex.zip" -d "$folder/apps/android/app/src/main/cpp/libs/arm64-v8a"
|
||||
|
||||
nix build "$folder#hydraJobs.armv7a-android:lib:simplex-chat.x86_64-linux"
|
||||
unzip -o "$PWD/result/pkg-armv7a-android-libsimplex.zip" -d "$folder/apps/android/app/src/main/cpp/libs/armeabi-v7a"
|
||||
|
||||
# Build android suppprt lib
|
||||
nix build "$folder#hydraJobs.aarch64-android:lib:support.x86_64-linux"
|
||||
unzip -o "$PWD/result/pkg-aarch64-android-libsupport.zip" -d "$folder/apps/android/app/src/main/cpp/libs/arm64-v8a"
|
||||
|
||||
nix build "$folder#hydraJobs.armv7a-android:lib:support.x86_64-linux"
|
||||
unzip -o "$PWD/result/pkg-armv7a-android-libsupport.zip" -d "$folder/apps/android/app/src/main/cpp/libs/armeabi-v7a"
|
||||
|
||||
sed -i.bak 's/${extract_native_libs}/true/' "$folder/apps/android/app/src/main/AndroidManifest.xml"
|
||||
sed -i.bak '/android {/a lint {abortOnError false}' "$folder/apps/android/app/build.gradle"
|
||||
|
||||
gradle -p "$folder/apps/android/" clean build assembleRelease
|
||||
|
||||
mkdir -p "$tmp/android"
|
||||
unzip -oqd "$tmp/android/" "$folder/apps/android/app/build/outputs/apk/release/app-release-unsigned.apk"
|
||||
mkdir -p "$tmp/android-aarch64"
|
||||
unzip -oqd "$tmp/android-aarch64/" "$folder/apps/android/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk"
|
||||
(cd "$tmp/android-aarch64" && zip -rq5 "$tmp/simplex-chat-aarch64.apk" . && zip -rq0 "$tmp/simplex-chat-aarch64.apk" resources.arsc res)
|
||||
zipalign -p -f 4 "$tmp/simplex-chat-aarch64.apk" "$PWD/simplex-chat-aarch64.apk"
|
||||
|
||||
(cd "$tmp/android" && zip -rq5 "$tmp/simplex-chat.apk" . && zip -rq0 "$tmp/simplex-chat.apk" resources.arsc res)
|
||||
|
||||
zipalign -p -f 4 "$tmp/simplex-chat.apk" "$PWD/simplex-chat.apk"
|
||||
mkdir -p "$tmp/android-armv7"
|
||||
unzip -oqd "$tmp/android-armv7/" "$folder/apps/android/app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned.apk"
|
||||
(cd "$tmp/android-armv7" && zip -rq5 "$tmp/simplex-chat-armv7.apk" . && zip -rq0 "$tmp/simplex-chat-armv7.apk" resources.arsc res)
|
||||
zipalign -p -f 4 "$tmp/simplex-chat-armv7.apk" "$PWD/simplex-chat-armv7.apk"
|
||||
}
|
||||
|
||||
final() {
|
||||
|
||||
@@ -18,29 +18,31 @@ fi
|
||||
|
||||
cd $apk_parent_dir
|
||||
|
||||
ORIG_NAME=$(echo app*.apk)
|
||||
unzip -o -q -d apk $ORIG_NAME
|
||||
ORIG_NAMES=( $(echo app*.apk) )
|
||||
for ORIG_NAME in "${ORIG_NAMES[@]}"; do
|
||||
unzip -o -q -d apk $ORIG_NAME
|
||||
|
||||
rm $ORIG_NAME
|
||||
rm $ORIG_NAME
|
||||
|
||||
(cd apk && zip -r -q -$level ../$ORIG_NAME .)
|
||||
# Shouldn't be compressed because of Android requirement
|
||||
(cd apk && zip -r -q -0 ../$ORIG_NAME resources.arsc)
|
||||
(cd apk && zip -r -q -0 ../$ORIG_NAME res)
|
||||
#(cd apk && 7z a -r -mx=$level -tzip -x!resources.arsc ../$ORIG_NAME .)
|
||||
#(cd apk && 7z a -r -mx=0 -tzip ../$ORIG_NAME resources.arsc)
|
||||
(cd apk && zip -r -q -$level ../$ORIG_NAME .)
|
||||
# Shouldn't be compressed because of Android requirement
|
||||
(cd apk && zip -r -q -0 ../$ORIG_NAME resources.arsc)
|
||||
(cd apk && zip -r -q -0 ../$ORIG_NAME res)
|
||||
#(cd apk && 7z a -r -mx=$level -tzip -x!resources.arsc ../$ORIG_NAME .)
|
||||
#(cd apk && 7z a -r -mx=0 -tzip ../$ORIG_NAME resources.arsc)
|
||||
|
||||
ALL_TOOLS=($sdk_dir/build-tools/*/)
|
||||
BIN_DIR="${ALL_TOOLS[1]}"
|
||||
ALL_TOOLS=($sdk_dir/build-tools/*/)
|
||||
BIN_DIR="${ALL_TOOLS[1]}"
|
||||
|
||||
$BIN_DIR/zipalign -p -f 4 $ORIG_NAME $ORIG_NAME-2
|
||||
$BIN_DIR/zipalign -p -f 4 $ORIG_NAME $ORIG_NAME-2
|
||||
|
||||
mv $ORIG_NAME{-2,}
|
||||
mv $ORIG_NAME{-2,}
|
||||
|
||||
$BIN_DIR/apksigner sign \
|
||||
--ks "$store_file" --ks-key-alias "$key_alias" --ks-pass "pass:$store_password" \
|
||||
--key-pass "pass:$key_password" $ORIG_NAME
|
||||
$BIN_DIR/apksigner sign \
|
||||
--ks "$store_file" --ks-key-alias "$key_alias" --ks-pass "pass:$store_password" \
|
||||
--key-pass "pass:$key_password" $ORIG_NAME
|
||||
|
||||
# cleanup
|
||||
rm -rf apk || true
|
||||
rm ${ORIG_NAME}.idsig 2> /dev/null || true
|
||||
# cleanup
|
||||
rm -rf apk || true
|
||||
rm ${ORIG_NAME}.idsig 2> /dev/null || true
|
||||
done
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
function readlink() {
|
||||
echo "$(cd "$(dirname "$1")"; pwd -P)"
|
||||
}
|
||||
|
||||
if [ -z "${1}" ]; then
|
||||
echo "Job repo is unset. Provide it via first argument like: $(readlink "$0")/download_libs.sh https://something.com/job/something/{master,stable}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
job_repo=$1
|
||||
default_arch=$2
|
||||
|
||||
arches=("aarch64" "armv7a")
|
||||
output_arches=("arm64-v8a" "armeabi-v7a")
|
||||
|
||||
if [ -z "${default_arch}" ]; then
|
||||
# No custom architectures were specified, using defaults
|
||||
echo "Libs for all supported architectures will be downloaded. To use single arch, pass one of the following values to the end of command: ${arches[*]}"
|
||||
else
|
||||
for ((i = 0 ; i < ${#output_arches[@]}; i++)); do
|
||||
if [ "${arches[$i]}" == "$default_arch" ]; then
|
||||
output_arches=("${output_arches[$i]}")
|
||||
fi
|
||||
done
|
||||
arches=("$default_arch")
|
||||
fi
|
||||
|
||||
root_dir="$(dirname "$(dirname "$(readlink "$0")")")"
|
||||
for ((i = 0 ; i < ${#arches[@]}; i++)); do
|
||||
arch="${arches[$i]}"
|
||||
output_arch="${output_arches[$i]}"
|
||||
output_dir="$root_dir/apps/android/app/src/main/cpp/libs/$output_arch/"
|
||||
|
||||
mkdir -p "$output_dir" 2> /dev/null
|
||||
|
||||
curl --location -o libsupport.zip $job_repo/$arch-android:lib:support.x86_64-linux/latest/download/1 && \
|
||||
unzip -o libsupport.zip && \
|
||||
mv libsupport.so "$output_dir" && \
|
||||
rm libsupport.zip
|
||||
|
||||
curl --location -o libsimplex.zip "$job_repo"/"$arch"-android:lib:simplex-chat.x86_64-linux/latest/download/1 && \
|
||||
unzip -o libsimplex.zip && \
|
||||
mv libsimplex.so "$output_dir" && \
|
||||
rm libsimplex.zip
|
||||
done
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
function readlink() {
|
||||
echo $(cd $(dirname $1); pwd -P)
|
||||
}
|
||||
|
||||
if [ -z ${1} ]; then
|
||||
echo "Job repo is unset. Provide it via first argument like: $(readlink $0)/download_libs_aarch64.sh https://something.com/job/something/{master,stable}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
job_repo=$1
|
||||
arch="aarch64"
|
||||
#arch="x86_64"
|
||||
output_arch="arm64-v8a"
|
||||
#output_arch="x86_64"
|
||||
|
||||
root_dir="$(dirname $(dirname $(readlink $0)))"
|
||||
output_dir="$root_dir/apps/android/app/src/main/cpp/libs/$output_arch/"
|
||||
|
||||
mkdir -p "$output_dir" 2> /dev/null
|
||||
|
||||
curl --location -o libsupport.zip $job_repo/$arch-android:lib:support.x86_64-linux/latest/download/1 && \
|
||||
unzip -o libsupport.zip && \
|
||||
mv libsupport.so "$output_dir" && \
|
||||
rm libsupport.zip
|
||||
|
||||
curl --location -o libsimplex.zip $job_repo/$arch-android:lib:simplex-chat.x86_64-linux/latest/download/1 && \
|
||||
unzip -o libsimplex.zip && \
|
||||
mv libsimplex.so "$output_dir" && \
|
||||
rm libsimplex.zip
|
||||
@@ -1,8 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# libsimplex.so and libsupport.so binaries should be in ~/Downloads folder
|
||||
# libsimplex.so and libsupport.so binaries should be in ~/Downloads folder in their directories based on archive name
|
||||
mkdir -p ./apps/android/app/src/main/cpp/libs/arm64-v8a/
|
||||
rm ./apps/android/app/src/main/cpp/libs/arm64-v8a/*
|
||||
cp ~/Downloads/libsupport.so ./apps/android/app/src/main/cpp/libs/arm64-v8a/
|
||||
cp ~/Downloads/pkg-aarch64-android-libsimplex/libsimplex.so ./apps/android/app/src/main/cpp/libs/arm64-v8a/
|
||||
cp ~/Downloads/pkg-aarch64-android-libsimplex/libcrypto.so ./apps/android/app/src/main/cpp/libs/arm64-v8a/
|
||||
unzip -o ~/Downloads/pkg-aarch64-android-libsupport.zip -d ./apps/android/app/src/main/cpp/libs/arm64-v8a
|
||||
unzip -o ~/Downloads/pkg-aarch64-android-libsimplex.zip -d ./apps/android/app/src/main/cpp/libs/arm64-v8a/
|
||||
|
||||
mkdir -p ./apps/android/app/src/main/cpp/libs/armeabi-v7a/
|
||||
rm ./apps/android/app/src/main/cpp/libs/armeabi-v7a/*
|
||||
unzip -o ~/Downloads/pkg-armv7a-android-libsupport.zip -d ./apps/android/app/src/main/cpp/libs/armeabi-v7a/
|
||||
unzip -o ~/Downloads/pkg-armv7a-android-libsimplex.zip -d ./apps/android/app/src/main/cpp/libs/armeabi-v7a/
|
||||
|
||||
Reference in New Issue
Block a user