build(ns5-android): add product flavors config

This commit is contained in:
pierre
2023-06-01 19:20:32 +02:00
parent 365e0134b4
commit 62ccb6b4cd
3 changed files with 93 additions and 22 deletions
+7 -8
View File
@@ -60,29 +60,28 @@ jobs:
working-directory: sdk/lib/socks5-listener/
env:
RELEASE: true
# build for arm64 and x86_64
run: ./build-android.sh aarch64 x86_64
- name: Build APKs (unsigned debug)
working-directory: nym-connect/native/android
env:
ANDROID_SDK_ROOT: ${{ env.ANDROID_HOME }}
run: ./gradlew :app:assembleDebug
# build for arm64 and x86_64
run: ./gradlew :app:assembleArch64Debug
- name: Prepare APKs
run: |
mkdir apk/
mv nym-connect/native/android/app/build/outputs/apk/debug/app-arm64-v8a-debug.apk \
apk/nyms5-arm64-debug.apk
mv nym-connect/native/android/app/build/outputs/apk/debug/app-x86_64-debug.apk \
apk/nyms5-x86_64-debug.apk
mkdir apk
mv nym-connect/native/android/app/build/outputs/apk/arch64/debug/app-arch64-debug.apk \
apk/nyms5-arch64-debug.apk
- name: Upload APKs
uses: actions/upload-artifact@v3
with:
name: nyms5-apk-debug
path: |
apk/nyms5-arm64-debug.apk
apk/nyms5-x86_64-debug.apk
apk/nyms5-arch64-debug.apk
# publish:
# name: Publish APK
+39 -7
View File
@@ -6,15 +6,22 @@ _TODO_
### Getting started
Install Android Studio and open the project.
[Install](https://developer.android.com/studio/install) Android Studio and open
the project.\
Setup an android emulator using AVD.\
[Run](https://developer.android.com/studio/run/emulator) the project.
**⚠ NOTE**: be sure
to [set](https://developer.android.com/studio/run#changing-variant)
the build variant to `x86_64Debug` when running on emulator
### Lib Nym socks5
This Application needs the native [nym-socks5-listener](https://github.com/nymtech/nym/blob/develop/sdk/lib/socks5-listener/Cargo.toml)
This Application needs the
native [nym-socks5-listener](https://github.com/nymtech/nym/blob/develop/sdk/lib/socks5-listener/Cargo.toml)
library in order to work.
To build it for arch x64 and arm (x64 is mainly for android emulator, arm
for APK distribution), from the root of the repo run
To build it for x86_64 and arm64 arch, from the root of the repo run
```shell
cd sdk/lib/socks5-listener/
@@ -24,10 +31,35 @@ cd sdk/lib/socks5-listener/
To build in release mode run
```shell
RELEASE=true ./build-android.sh aarch64
RELEASE=true ./build-android.sh aarch64 x86_64
```
The shared library for each ABIs will be automatically moved into
The shared library for each ABIs will be automatically moved into
`app/src/main/jniLibs/*` directories.
### Run _TODO_
### APK build (from terminal)
This project is setup with multiple [product flavors](app/build.gradle) to
build for specific architectures.\
Supported archs:
- arm64
- arm (old arm)
- x86_64
- x86
For example to build for _arm64_ in _release_ mode use
```shell
./gradlew :app:assembleArm64Release
```
**NOTE**: you likely want _arch64_ (`arm64` & `x86_64`) for APK distribution
To build a _universal_ APK which includes all ABI use
```shell
./gradlew :app:assembleUniversalRelease
```
**⚠ WARNING**: APK size will be multiplied
+47 -7
View File
@@ -23,20 +23,60 @@ android {
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
splits {
abi {
enable true
reset()
include "x86_64", "arm64-v8a"
universalApk true
flavorDimensions "abi"
productFlavors {
universal {
dimension "abi"
ndk {
abiFilters "arm64-v8a", "armeabi-v7a", "x86_64", "x86"
}
}
arch64 {
dimension "abi"
ndk {
abiFilters "arm64-v8a", "x86_64"
}
}
arm64 {
dimension "abi"
ndk {
abiFilters "arm64-v8a"
}
}
arm {
dimension "abi"
ndk {
abiFilters "armeabi-v7a"
}
}
x86_64 {
dimension "abi"
ndk {
abiFilters "x86_64"
}
}
x86 {
dimension "abi"
ndk {
abiFilters "x86"
}
}
}
// splits {
// abi {
// enable true
// reset()
// include "x86_64", "arm64-v8a"
// universalApk true
// }
// }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8