Commit 1e87366b authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Rework Android APK generation

Summary: This reworks the APK generation to be more aligned to what the binary factory Android builder expects. Most of the heavy lifting is done there for us, so we don't need special code for it here.

Test Plan: Builds in local clone of the binary factory container

Reviewers: #marble, sanjibanb

Reviewed By: sanjibanb

Subscribers: apol, marble-devel, kde-edu

Tags: #marble, #kde_edu

Differential Revision: https://phabricator.kde.org/D24642
parent ed30aee9
......@@ -3,20 +3,18 @@ qt5_add_resources(marble_QRCS MarbleMaps.qrc)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_SYSTEM_NAME STREQUAL Android)
set(TARGET Marble)
add_executable(marble-maps ${marble_SRCS} ${marble_QRCS})
if (ANDROID)
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED
COMPONENTS
AndroidExtras
QuickControls2
)
add_library (${TARGET} SHARED ${marble_SRCS} ${marble_QRCS})
# while not directly linked, need to be listed here to have deployqt pick up those libs
target_link_libraries (
${TARGET}
marble-maps
marblewidget
astro
Qt5::Concurrent
......@@ -35,54 +33,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL Android)
if (TARGET Qt5::WebEngineWidgets)
target_link_libraries(${TARGET} Qt5::WebEngineWidgets Qt5::WebEngine)
endif()
else()
set(TARGET marble-maps)
add_executable (${TARGET} ${marble_SRCS} ${marble_QRCS})
endif()
target_link_libraries (
${TARGET}
marble-maps
marbledeclarative
)
FILE(GLOB QML_FILES *.qml)
add_custom_target(marble-maps_resources ALL SOURCES ${QML_FILES} package/AndroidManifest.xml)
if (CMAKE_SYSTEM_NAME STREQUAL Android)
install(DIRECTORY "../../../data/android/" DESTINATION "${CMAKE_INSTALL_PREFIX}/res")
set(ABSOLUTE_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}")
if(NOT IS_ABSOLUTE "${ABSOLUTE_INSTALL_PATH}")
set(ABSOLUTE_INSTALL_PATH "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}")
endif()
get_filename_component(ABSOLUTE_INSTALL_PATH "${ABSOLUTE_INSTALL_PATH}" ABSOLUTE)
get_filename_component(QT_ANDROID_QT_ROOT "${Qt5Core_DIR}/../../.." ABSOLUTE)
set(ANDROID_SDK_ROOT $ENV{ANDROID_SDK_ROOT})
set(ANDROID_NDK_ROOT $ENV{ANDROID_NDK_ROOT})
set(QT_ANDROID_APP_PATH "${ABSOLUTE_INSTALL_PATH}/libs/${ANDROID_ABI}/libMarble.so")
set(QT_ANDROID_APP_EXTRA_LIBS "${ABSOLUTE_INSTALL_PATH}/lib/libastro.so,${ABSOLUTE_INSTALL_PATH}/lib/libmarblewidget-qt5.so,${ABSOLUTE_INSTALL_PATH}/lib/libmarbledeclarative.so")
set(QT_ANDROID_APP_PACKAGE_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/package")
set(QT_ANDROID_APP_PACKAGE_NAME "org.kde.marble.maps")
set(QT_ANDROID_APP_NAME "Marble Maps")
set(QT_ANDROID_APP_EXTRA_PLUGINS "${ABSOLUTE_INSTALL_PATH}//share,${ABSOLUTE_INSTALL_PATH}//lib/qml")
configure_file(package/deploy-marble-maps.json.in ${CMAKE_CURRENT_BINARY_DIR}/deploy-marble-maps.json @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/deploy-marble-maps.json DESTINATION "${CMAKE_INSTALL_PREFIX}/share")
install(TARGETS ${TARGET} LIBRARY DESTINATION libs/${ANDROID_ABI})
if (TARGET create-apk-Marble)
set(PACKAGE_DIR "${CMAKE_BINARY_DIR}/Marble_projects/")
set_target_properties(create-apk-Marble PROPERTIES ANDROID_APK_DIR "${PACKAGE_DIR}")
add_custom_target(marble-move-metadata ALL
COMMAND cmake -E echo "Moving Marble shared Android resources"
COMMAND cmake -E remove_directory "${PACKAGE_DIR}"
COMMAND cmake -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/package" "${PACKAGE_DIR}"
COMMAND cmake -E copy_directory "${CMAKE_SOURCE_DIR}/data/android/" "${PACKAGE_DIR}/res"
)
add_dependencies(create-apk-Marble marble-move-metadata)
endif()
else()
if(MARBLE_INSTALL_ANDROID_APPS)
if(APPS_INSTALL_DIR)
install(PROGRAMS org.kde.marble.maps.desktop DESTINATION ${APPS_INSTALL_DIR})
endif(APPS_INSTALL_DIR)
install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
endif()
endif()
......@@ -19,7 +19,7 @@
<data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.osm"/>
<data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.geojson"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="Marble"/>
<meta-data android:name="android.app.lib_name" android:value="marble-maps"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
......
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
compile 'com.android.support:support-v4:28.0.0'
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
{
"description": "This file is to be read by androiddeployqt",
"qt": "@QT_ANDROID_QT_ROOT@",
"sdk": "@ANDROID_SDK_ROOT@",
"ndk": "@ANDROID_NDK_ROOT@",
"toolchain-prefix": "@ANDROID_TOOLCHAIN@",
"tool-prefix": "@ANDROID_TOOLCHAIN@",
"toolchain-version": "@ANDROID_GCC_VERSION@",
"ndk-host": "@_HOST@",
"target-architecture": "@ANDROID_ABI@",
"application-binary": "@QT_ANDROID_APP_PATH@",
"android-package": "@QT_ANDROID_APP_PACKAGE_NAME@",
"android-app-name": "@QT_ANDROID_APP_NAME@",
"android-extra-libs": "@QT_ANDROID_APP_EXTRA_LIBS@",
"android-extra-plugins": "@QT_ANDROID_APP_EXTRA_PLUGINS@",
"android-package-source-directory": "@QT_ANDROID_APP_PACKAGE_SOURCE_ROOT@"
}
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid android:color="#FFFFFF"/>
</shape>
</item>
<item android:width="256dp" android:height="256dp" android:gravity="center">
<bitmap
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/splash_logo" />
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment