android: Add support for split APKs to gradle

Currently a single huge APK is produced. For GooglePlay that doesn't
matter since since they require a complete bundle, while creating
stripped and optimised APKs per device.

For alternative downloads - be that directly or via fdroid-like repo
currently we download/store about four times more information than
needed.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Change-Id: Ic43ef6a3f3e072323ecd57448552379113123e9c
pull/1743/head
Emil Velikov 2021-01-29 20:44:08 +00:00 committed by Yunusemre Şentürk
parent c9681a2461
commit ed85b0a9d9
7 changed files with 23 additions and 9 deletions

View File

@ -2,6 +2,7 @@
/app.iml
/build
/appSettings.gradle
/build.gradle
/src/main/res/drawable/ic_launcher_brand.xml
/src/main/res/drawable/drawer_header_brand.png
/src/main/res/mipmap-anydpi-v26/ic_launcher_brand.xml

View File

@ -5,7 +5,6 @@ ext {
liboLauncherIcon = '@mipmap/@APP_IC_LAUNCHER@'
liboHasBranding = '@APP_HAS_BRANDING@'
liboBrandingDir = '@APP_BRANDING_DIR@'
liboAndroidAbi = '@ANDROID_ABI@'
liboOVersionHash = '@LOOLWSD_VERSION_HASH@'
liboCoreVersionHash = '@CORE_VERSION_HASH@'

View File

@ -20,9 +20,13 @@ android {
resValue "string", "image_draw_header", "@drawable/drawer_header"
manifestPlaceholders = [ appIcon: "${liboLauncherIcon}" ]
buildConfigField "boolean", "APP_HAS_BRANDING", "${liboHasBranding}"
ndk {
abiFilters = []
abiFilters.addAll("${liboAndroidAbi}".split(' ').collect{it as String})
}
splits {
abi {
enable true
reset ()
include @ANDROID_ABI_SPLIT@
}
}

View File

@ -1,3 +1,4 @@
/build
/lib.iml
/build.gradle
/libSettings.gradle

View File

@ -16,10 +16,6 @@ android {
resValue "string", "app_name", "${liboAppName}"
buildConfigField "String", "GIT_COMMIT", "\"${liboOVersionHash}\""
buildConfigField "boolean", "GOOGLE_PLAY_ENABLED", "${liboGooglePlay}"
ndk {
abiFilters = []
abiFilters.addAll("${liboAndroidAbi}".split(' ').collect{it as String})
}
externalNativeBuild {
cmake {
@ -28,6 +24,15 @@ android {
}
}
splits {
abi {
enable true
reset ()
include @ANDROID_ABI_SPLIT@
}
}
lintOptions {
disable 'MissingTranslation', 'ExtraTranslation'
}

View File

@ -9,6 +9,5 @@ ext {
liboCoreVersionHash = '@CORE_VERSION_HASH@'
liboApplicationId = '@ANDROID_PACKAGE_NAME@'
liboBrandingDir = '@APP_BRANDING_DIR@'
liboAndroidAbi = '@ANDROID_ABI@'
liboGooglePlay = '@APP_GOOGLE_PLAY@'
}

View File

@ -366,6 +366,7 @@ fi
# Android: We need these to setup the CMakeLists.txt properly.
LOBUILDDIR=
ANDROID_ABI="armeabi-v7a"
ANDROID_ABI_SPLIT="'armeabi-v7a'"
LOBUILDDIR_ARM64_V8A=
LOBUILDDIR_X86=
LOBUILDDIR_X86_64=
@ -389,6 +390,7 @@ if test \( "$enable_iosapp" = "yes" -a `uname -s` = "Darwin" \) -o \( "$enable_a
ANDROID_ABI="armeabi-v7a arm64-v8a x86 x86_64"
fi
fi
ANDROID_ABI_SPLIT=`echo $ANDROID_ABI | sed "s/^/'/g;s/ /','/g;s/$/'/g"`
AC_MSG_RESULT([$ANDROID_ABI])
fi
@ -539,6 +541,7 @@ if test \( "$enable_iosapp" = "yes" -a `uname -s` = "Darwin" \) -o \( "$enable_a
fi
AC_SUBST(LOBUILDDIR)
AC_SUBST(ANDROID_ABI)
AC_SUBST(ANDROID_ABI_SPLIT)
AC_SUBST(LOBUILDDIR_ARM64_V8A)
AC_SUBST(LOBUILDDIR_X86)
AC_SUBST(LOBUILDDIR_X86_64)
@ -1188,6 +1191,8 @@ fi
if test "$enable_androidapp" = "yes"; then
AC_CONFIG_FILES([$srcdir/android/build.gradle:android/build.gradle.in
$srcdir/android/app/build.gradle:android/app/build.gradle.in
$srcdir/android/lib/build.gradle:android/lib/build.gradle.in
$srcdir/android/app/appSettings.gradle:android/app/appSettings.gradle.in
$srcdir/android/lib/libSettings.gradle:android/lib/libSettings.gradle.in
$srcdir/android/lib/src/main/cpp/CMakeLists.txt:android/lib/src/main/cpp/CMakeLists.txt.in])