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

View File

@@ -2,11 +2,14 @@
Notes and resources for MPD android maintainers. 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 ## Android studio
### Version control ### Version control
git ignoring .idea directory completely until a good reason emerges not to 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) * [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) * [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: The required permission depends on android SDK version:
@@ -29,7 +31,7 @@ The required permission depends on android SDK version:
else else
Manifest.permission.READ_EXTERNAL_STORAGE Manifest.permission.READ_EXTERNAL_STORAGE
#### Permission request ### Permission request
[Request runtime permissions](https://developer.android.com/training/permissions/requesting) [Request runtime permissions](https://developer.android.com/training/permissions/requesting)

View File

@@ -18,11 +18,6 @@ android {
vectorDrawables { vectorDrawables {
useSupportLibrary = true useSupportLibrary = true
} }
ndk {
// Specifies the ABI configurations of your native
// libraries Gradle should build and package with your app.
abiFilters += "arm64-v8a"
}
} }
buildFeatures { 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 { compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_9 sourceCompatibility = JavaVersion.VERSION_1_9
targetCompatibility = JavaVersion.VERSION_1_9 targetCompatibility = JavaVersion.VERSION_1_9
} }
kotlinOptions { kotlinOptions {
jvmTarget = "9" jvmTarget = JavaVersion.VERSION_1_9.toString()
} }
packaging { packaging {
resources { resources {

View File

@@ -70,3 +70,11 @@ ninja = shutil.which("ninja")
subprocess.check_call([ninja], env=toolchain.env) subprocess.check_call([ninja], env=toolchain.env)
subprocess.check_call([ninja, 'install'], 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()))

View File

@@ -223,11 +223,14 @@ tarball and change into the directory. Then, instead of
-Dwrap_mode=forcefallback \ -Dwrap_mode=forcefallback \
-Dandroid_debug_keystore=$HOME/.android/debug.keystore -Dandroid_debug_keystore=$HOME/.android/debug.keystore
cd ../../android 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 :envvar:`SDK_PATH` is the absolute path where you installed the
Android SDK; :envvar:`NDK_PATH` is the Android NDK installation path; 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`. This downloads various library sources, and then configures and builds :program:`MPD`.