Files
core/android/source/build.gradle
Michael Weghorn 2b77994d45 android: Update compile/targetSdkVersion to 35, disable edge-to-edge
Update compileSdk and targetSdkVersion to 35 (Android 15).

In a quick test, running the app seems fine in an API 36 (Android 16)
AVD configured to use 16 KB Page Size, for which support was added
in Android 15 [1].

Changing the targetSdkVersion to 35 implies that edge-to-edge
would now enabled by default [2]. That would result in the
app par overlapping with the system bar and interaction would
be broken. For now, avoid that by explicitly opting out of
edge-to-edge support by setting
android:windowOptOutEdgeToEdgeEnforcement for API versions >= 35
in the LibreOfficeTheme used by all activities by now.

Helpful article: [3]

That won't work for targetSdkVersion 36 any more (see [4]),
but at least helps to comply with the upcoming required
targetSdkVersion of 35 in Google Play and gives some time
to implement proper support for edge-to-edge
for Android 16+ devices before increasing the targetSdkVersion
further.

Android Viewer works as expected in a quick test
with an API 36 (Android 16) x86_64 AVD
and an API 24 (Android 7) x86 AVD (with an additional
local revert of commit 9d1e76f7da
to prevent a deadlock when opening documents that is unrelated
to this change here).

[1] https://developer.android.com/about/versions/15/behavior-changes-all
[2] https://developer.android.com/about/versions/15/behavior-changes-15#window-insets
[3] https://medium.com/androiddevelopers/insets-handling-tips-for-android-15s-edge-to-edge-enforcement-872774e8839b
[4] https://developer.android.com/about/versions/16/behavior-changes-16#edge-to-edge

Change-Id: Id6d33bfbb7ca49c65e3875efb87c3c575be5f5ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187627
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-07-11 07:09:32 +02:00

315 lines
11 KiB
Groovy

apply plugin: 'com.android.application'
// buildhost settings - paths and the like
apply from: 'liboSettings.gradle'
allprojects {
repositories {
mavenCentral()
maven {
url "https://ipv6.repo1.maven.org/maven2"
}
google()
}
}
//build-time dependencies - android plugin for gradle
buildscript {
repositories {
mavenCentral()
maven {
url "https://ipv6.repo1.maven.org/maven2"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.11.0'
}
}
// compile-time dependencies
dependencies {
implementation fileTree(dir: "${liboInstdir}/${liboUREJavaFolder}", include: [
"java_uno.jar",
"libreoffice.jar",
"unoloader.jar"
])
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
implementation 'androidx.preference:preference:1.2.1'
}
base {
archivesName = "LibreOfficeViewer"
}
android {
namespace 'org.libreoffice'
compileSdk 35
buildFeatures {
buildConfig = true
}
// uses non-conventional source layout, so need to reconfigure accordingly
// ToDo move to conventional layout, so stuff can be stripped down.
sourceSets {
main.manifest.srcFile 'AndroidManifest.xml'
main.assets.srcDirs = ['assets']
main.res.srcDirs = ['res', 'res_generated']
main.java.srcDirs = ['../Bootstrap/src', 'src/java']
main.jniLibs.srcDirs = ["${liboJniLibsdir}"]
strippedUI.assets.srcDirs 'assets_strippedUI'
strippedUIEditing.assets.srcDirs 'assets_strippedUI'
}
defaultConfig {
// minSdkVersion is set in liboSettings.gradle
targetSdkVersion 35
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
// make android studio happy...
jniDebuggable true
// would work just fine with external, but setting emulator up is a little more work
manifestPlaceholders = [installLocation: "auto"]
}
release {
manifestPlaceholders = [installLocation: "preferExternal"]
}
}
flavorDimensions "default"
productFlavors {
strippedUI {
dimension "default"
buildConfigField 'boolean', 'ALLOW_EDITING', 'false'
}
strippedUIEditing {
dimension "default"
buildConfigField 'boolean', 'ALLOW_EDITING', 'true'
}
}
lint {
warningsAsErrors true
// ignore missing or extra translations, since these are tracked/managed via Weblate
disable 'ExtraTranslation', 'MissingTranslation'
// don't error-out on external updates (new gradle plugin, library versions
// or target API become available)
// don't error-out on TypographyEllipsis, since this can be introduced with
// new translations, and those are handled in Weblate
informational 'AndroidGradlePluginVersion', 'GradleDependency', 'NewerVersionAvailable', 'OldTargetApi', 'TypographyEllipsis'
// don't fail on pre-existing issues
// These should be dealt with at some point, though.
// To update lint-baseline.xml, just remove the file and run the build again.
baseline file("lint-baseline.xml")
// s.a. lint.xml that contains further config
}
}
// show warnings about use of deprecated API
tasks.withType(JavaCompile).configureEach {
options.deprecation = true
}
/* remark inherited from makefile:
Then "assets". Let the directory structure under assets mimic
that under solver for now.
Please note that I have no idea what all of this is really necessary and for
much of this stuff being copied, no idea whether it makes any sense at all.
Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
unit tests for sc are built, and those do seem to mostly work) and
android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
extent)
*/
// Assets that are unpacked at run-time into the app's data directory. These
// are files read by non-LO code, fontconfig and freetype for now, that doesn't
// understand "/assets" paths.
task copyUnpackAssets(type: Copy) {
description "copies assets that need to be extracted on the device"
into 'assets/unpack'
into('program') {
from("${liboInstdir}/${liboEtcFolder}/types") {
includes = [
"offapi.rdb",
"oovbaapi.rdb"
]
}
from("${liboInstdir}/${liboUreMiscFolder}") {
includes = ["types.rdb"]
rename 'types.rdb', 'udkapi.rdb'
}
}
into('user/fonts') {
from "${liboInstdir}/share/fonts/truetype"
// Note: restrict list of fonts due to size considerations - no technical reason anymore
// ToDo: fonts would be good candidate for using Expansion Files instead
includes = [
"Liberation*.ttf",
"Caladea-*.ttf",
"Carlito-*.ttf",
"Gen*.ttf",
"opens___.ttf"
]
}
into('etc/fonts') {
from "./"
includes = ['fonts.conf']
filter {
String line ->
line.replaceAll(
'@@APPLICATION_ID@@', new String("${android.defaultConfig.applicationId}")
)
}
}
}
task copyAssets(type: Copy) {
description "copies assets that can be accessed within the installed apk"
into 'assets'
// include icons, Impress styles and required .ui files
into ('share') {
into ('config') {
from ("${liboInstdir}/share/config")
includes = ['images_**.zip',
'**/simpress/**.xml',
'**/annotation.ui',
'**/hfmenubutton.ui',
'**/inforeadonlydialog.ui',
'**/pbmenubutton.ui',
'**/scrollbars.ui',
'**/tabbuttons.ui',
'**/tabbuttonsmirrored.ui',
'**/tabviewbar.ui'
]
}
}
into('program') {
from "${liboInstdir}/program"
includes = ['services.rdb', 'services/services.rdb']
into('resource') {
from "${liboInstdir}/${liboSharedResFolder}"
includes = ['*en-US.res']
}
}
into('share') {
from("${liboInstdir}/share") {
// Filter data is needed by e.g. the drawingML preset shape import.
includes = ['registry/**', 'filter/**']
// those two get processed by mobile-config.py
excludes = ['registry/main.xcd', 'registry/res/registry_en-US.xcd']
}
// separate data files for Chinese and Japanese
from("${liboWorkdir}/CustomTarget/i18npool/breakiterator/") {
include '*.data'
}
}
}
task copyAppResources(type: Copy) {
description "copies documents to make them available as app resources"
into 'res_generated/raw'
from("${liboInstdir}") {
includes = ["LICENSE", "NOTICE"]
rename "LICENSE", "license.txt"
rename "NOTICE", "notice.txt"
}
}
task createStrippedConfig {
def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
outputs.dir "assets_strippedUI"
outputs.dir "assets_strippedUI/share/registry/res"
outputs.file preserveDir
doLast {
file('assets_strippedUI/share/registry/res').mkdirs()
file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
// just empty file
preserveDir.text = ""
}
}
task createStrippedConfigMain(type: Exec) {
dependsOn 'createStrippedConfig'
inputs.files "${liboInstdir}/share/registry/main.xcd", "${liboSrcRoot}/android/mobile-config.py"
outputs.file "assets_strippedUI/share/registry/main.xcd"
executable "${liboSrcRoot}/android/mobile-config.py"
args = ["${liboInstdir}/share/registry/main.xcd", "assets_strippedUI/share/registry/main.xcd"]
}
task createStrippedConfigRegistry(type: Exec) {
dependsOn 'createStrippedConfig'
inputs.files "${liboInstdir}/share/registry/res/registry_en-US.xcd", "${liboSrcRoot}/android/mobile-config.py"
outputs.file "assets_strippedUI/share/registry/res/registry_en-US.xcd"
executable "${liboSrcRoot}/android/mobile-config.py"
args = ["${liboInstdir}/share/registry/res/registry_en-US.xcd", "assets_strippedUI/share/registry/res/registry_en-US.xcd"]
doFirst {
file('assets_strippedUI/share/registry/res').mkdirs()
}
}
task createRCfiles {
inputs.file "liboSettings.gradle"
dependsOn copyUnpackAssets, copyAssets
def sofficerc = file('assets/unpack/program/sofficerc')
def fundamentalrc = file('assets/program/fundamentalrc')
def bootstraprc = file('assets/program/bootstraprc')
def unorc = file('assets/program/unorc')
def versionrc = file('assets/program/versionrc')
outputs.files sofficerc, fundamentalrc, unorc, bootstraprc, versionrc
doLast {
sofficerc.text = '''\
[Bootstrap]
Logo=1
NativeProgress=1
URE_BOOTSTRAP=file:///assets/program/fundamentalrc
HOME=$APP_DATA_DIR/cache
OSL_SOCKET_PATH=$APP_DATA_DIR/cache
'''.stripIndent()
fundamentalrc.text = '''\
[Bootstrap]
LO_LIB_DIR=file://$APP_DATA_DIR/lib/
BRAND_BASE_DIR=file:///assets
BRAND_SHARE_SUBDIR=share
CONFIGURATION_LAYERS=xcsxcu:${BRAND_BASE_DIR}/share/registry res:${BRAND_BASE_DIR}/share/registry
URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway
'''.stripIndent()
bootstraprc.text = '''\
[Bootstrap]
InstallMode=<installmode>
ProductKey=LibreOffice '''+ "${liboVersionMajor}.${liboVersionMinor}" + '''
UserInstallation=file://$APP_DATA_DIR
'''.stripIndent()
unorc.text = '''\
[Bootstrap]
URE_INTERNAL_LIB_DIR=file://$APP_DATA_DIR/lib/
UNO_TYPES=file://$APP_DATA_DIR/program/udkapi.rdb file://$APP_DATA_DIR/program/offapi.rdb file://$APP_DATA_DIR/program/oovbaapi.rdb
UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb
'''.stripIndent()
versionrc.text = '''\
[Version]
AllLanguages=en-US
buildid=''' + "${liboGitFullCommit}" + '''
ReferenceOOoMajorMinor=4.1
'''.stripIndent()
}
}
// creating the UI stuff is cheap, don't bother only applying it for the flavor...
preBuild.dependsOn 'createRCfiles',
'createStrippedConfigMain',
'createStrippedConfigRegistry',
'copyAppResources'
clean.dependsOn 'cleanCopyAssets',
'cleanCreateStrippedConfig'