From cbb022ac503dcdfadeed632b9da7159c0c641d11 Mon Sep 17 00:00:00 2001 From: ardocrat Date: Thu, 27 Jun 2024 12:30:51 +0300 Subject: [PATCH] build: fix android --- scripts/android.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/android.sh b/scripts/android.sh index b3bd17b..5aa7579 100755 --- a/scripts/android.sh +++ b/scripts/android.sh @@ -39,21 +39,29 @@ type=$1 [[ $2 == "v8" ]] && rustup target install aarch64-linux-android # Build native code -export CPPFLAGS="-DMDB_USE_ROBUST=0" && export CFLAGS="-DMDB_USE_ROBUST=0" \ -&& cargo ndk -t ${arch} build ${release_param[@]} +mkdir -p android/app/src/main/jniLibs +cargo install cargo-ndk +cargo ndk -t ${arch} -o android/app/src/main/jniLibs build ${release_param} # Build Android application and launch at all connected devices if [ $? -eq 0 ] then - yes | mkdir -p android/app/src/main/jniLibs/${arch} && cp -f target/${platform}/${type}/libgrim.so android/app/src/main/jniLibs/${arch} cd android + + # Setup gradle argument + [[ $1 == "release" ]] && gradle_param+=(assembleRelease) + [[ $1 == "debug" ]] && gradle_param+=(build) + ./gradlew clean -# ./gradlew assembleRelease - ./gradlew build + ./gradlew ${gradle_param} + + # Setup apk path + [[ $1 == "release" ]] && apk_path+=(app/build/outputs/apk/release/app-release.apk) + [[ $1 == "debug" ]] && apk_path+=(app/build/outputs/apk/debug/app-debug.apk) + for SERIAL in $(adb devices | grep -v List | cut -f 1); do -# adb -s $SERIAL install app/build/outputs/apk/release/app-release.apk - adb -s $SERIAL install app/build/outputs/apk/debug/app-debug.apk + adb -s $SERIAL install ${apk_path} sleep 1s adb -s $SERIAL shell am start -n mw.gri.android/.MainActivity; done