android: added product flavors to separatly build apk for arm64-v8a or x86_64

This commit is contained in:
gd 2025-02-04 10:22:17 +02:00
parent 834d6dcf46
commit 034bcf4f44
4 changed files with 38 additions and 13 deletions

@ -2,11 +2,14 @@
Notes and resources for MPD android maintainers.
## Build
See [Compiling for Android](https://github.com/MusicPlayerDaemon/MPD/blob/45cb098cd765af12316f8dca5635ef10a852e013/doc/user.rst#compiling-for-android)
## Android studio
### Version control
git ignoring .idea directory completely until a good reason emerges not to
* [How to manage projects under Version Control Systems (jetbrains.com)](https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems)
@ -17,10 +20,9 @@ git ignoring .idea directory completely until a good reason emerges not to
* [Include prebuilt native libraries (developer.android.com)](https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs)
## Permissions
### Permissions
#### Files access
### Files access
The required permission depends on android SDK version:
@ -29,7 +31,7 @@ The required permission depends on android SDK version:
else
Manifest.permission.READ_EXTERNAL_STORAGE
#### Permission request
### Permission request
[Request runtime permissions](https://developer.android.com/training/permissions/requesting)

@ -18,11 +18,6 @@ android {
vectorDrawables {
useSupportLibrary = true
}
ndk {
// Specifies the ABI configurations of your native
// libraries Gradle should build and package with your app.
abiFilters += "arm64-v8a"
}
}
buildFeatures {
@ -46,12 +41,29 @@ android {
)
}
}
// flavors
flavorDimensions += "base"
productFlavors {
create("arm64-v8a") {
ndk {
// ABI to include in package
//noinspection ChromeOsAbiSupport
abiFilters += listOf("arm64-v8a")
}
}
create("x86_64") {
ndk {
// ABI to include in package
abiFilters += listOf("x86_64")
}
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9
}
kotlinOptions {
jvmTarget = "9"
jvmTarget = JavaVersion.VERSION_1_9.toString()
}
packaging {
resources {

@ -70,3 +70,11 @@ ninja = shutil.which("ninja")
subprocess.check_call([ninja], env=toolchain.env)
subprocess.check_call([ninja, 'install'], env=toolchain.env)
print("""
-------------------------------------
## To build the android app:
# cd ../../android
# ./gradlew assemble{}Debug
-------------------------------------
""".format(android_abi.capitalize()))

@ -223,11 +223,14 @@ tarball and change into the directory. Then, instead of
-Dwrap_mode=forcefallback \
-Dandroid_debug_keystore=$HOME/.android/debug.keystore
cd ../../android
./gradlew assembleDebug
./gradlew assemble{ABI}Debug
In the argument to `gradlew`, replace `{ABI}` with the build ABI.
The `productFlavor` names defined in `build.android.kts` match the ABI.
:envvar:`SDK_PATH` is the absolute path where you installed the
Android SDK; :envvar:`NDK_PATH` is the Android NDK installation path;
ABI is the Android ABI to be built, e.g. ":code:`arm64-v8a`".
ABI is the Android ABI to be built, e.g. ":code:`x86`, `x86_64`, `armeabi`, `armeabi-v7a`, `arm64-v8a`".
This downloads various library sources, and then configures and builds :program:`MPD`.