Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce APK size, add debug symbols to AAB #2790

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ app/android/AndroidManifest.xml
*.gpkg-shm
Input_keystore.keystore
CMakeLists.txt.user
app/android/build.gradle
app/android/.gradle/*
app/android/.gradle
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if (DEFINED ENV{INPUT_SDK_ANDROID_BASE})
# Target/Minimum API levels for Android, used as Input target properties
set(INPUT_ANDROID_TARGET_SDK_VERSION "33")
set(INPUT_ANDROID_MIN_SDK_VERSION "${ANDROIDAPI}")
set(INPUT_ANDROID_NDK_PATH "$ENV{ANDROID_NDK_ROOT}")
if (NOT INPUT_ANDROID_NDK_PATH)
message(FATAL_ERROR "Set required environment variable ANDROID_NDK_ROOT.")
endif ()
endif ()

if (IOS)
Expand Down Expand Up @@ -173,7 +177,16 @@ message(STATUS "Mergin Maps Input ${version_desc} - ${platform_desc}")

if (ANDROID)
set(INPUT_SDK_PATH_ANDROID_ABI_armeabi-v7a ${INPUT_SDK_PATH}/arm-android)

if (NOT EXISTS ${INPUT_SDK_PATH_ANDROID_ABI_armeabi-v7a})
message(WARNING "INPUT_SDK_PATH arm-android directory does not exist!")
endif ()

set(INPUT_SDK_PATH_ANDROID_ABI_arm64-v8a ${INPUT_SDK_PATH}/arm64-android)
if (NOT EXISTS ${INPUT_SDK_PATH_ANDROID_ABI_arm64-v8a})
message(WARNING "INPUT_SDK_PATH arm64-android directory does not exist!")
endif ()

set(INPUT_SDK_PATH_MULTI ${INPUT_SDK_PATH_ANDROID_ABI_${ANDROID_ABI}})
# allow libraries outside of SDK/NDK directory
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
Expand Down Expand Up @@ -215,7 +228,7 @@ if (NOT IOS)
)
endif ()

if (NOT LINUX)
if (NOT LNX)
find_package(Charset REQUIRED)
find_package(Iconv REQUIRED)
endif ()
Expand Down Expand Up @@ -376,10 +389,6 @@ if (IOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-shorten-64-to-32")
endif ()

if (ANDROID)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g0")
endif ()

# ########################################################################################
# SUBDIRECTORIES
# ########################################################################################
Expand Down
11 changes: 10 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ if (ANDROID)
${INPUT_CMAKE_TEMPLATES_PATH}/AndroidManifest.xml.in
${CMAKE_CURRENT_SOURCE_DIR}/android/AndroidManifest.xml @ONLY
)

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/android/build.gradle)
file(REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/android/build.gradle)
endif ()
configure_file(
${INPUT_CMAKE_TEMPLATES_PATH}/build.gradle.in
${CMAKE_CURRENT_SOURCE_DIR}/android/build.gradle @ONLY
)

set_target_properties(
Input
PROPERTIES QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android
Expand Down Expand Up @@ -471,7 +480,7 @@ target_link_libraries(
Spatialite::Spatialite
)

if (NOT LINUX)
if (NOT LNX)
target_link_libraries(Input PUBLIC Charset::Charset Iconv::Iconv)
endif ()

Expand Down
12 changes: 10 additions & 2 deletions app/android/build.gradle → cmake_templates/build.gradle.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/* keep in sync with /opt/Qt/<ver>/android//src/android/templates/build.gradle */

buildscript {
ext {
buildToolsVersion = androidBuildToolsVersion
compileSdkVersion = androidCompileSdkVersion.toInteger()
targetSdkVersion = androidCompileSdkVersion.toInteger()
ndkVersion = androidNdkVersion
}

repositories {
google()
mavenCentral()
Expand Down Expand Up @@ -44,7 +51,8 @@ android {
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
ndkVersion androidNdkVersion

ndkPath '@INPUT_ANDROID_NDK_PATH@'

packagingOptions.jniLibs.useLegacyPackaging true

sourceSets {
Expand Down Expand Up @@ -83,6 +91,6 @@ android {
minSdkVersion qtMinSdkVersion
targetSdkVersion qtTargetSdkVersion
ndk.abiFilters = qtTargetAbiList.split(",")
ndk.debugSymbolLevel "FULL"
ndk.debugSymbolLevel "SYMBOL_TABLE"
}
}