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

ViSP Android module #1566

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
76e5e99
[FIX] Added missing namespace and options due to change of default va…
Jan 27, 2025
02b8d93
[FIX] Force the build of the JAVA module
Jan 27, 2025
34ca240
[FIX] Add compilation flag to fix 'dlopen failed: library libomp.so n…
Jan 28, 2025
4ddd372
[FIX] Fix wrong version number variables in build.gradle template
Jan 28, 2025
07e7d4a
[CORE] Added configuration file for NDK 28
Jan 28, 2025
8e27faa
[CORE] Updated CMake files to detect the tools that are nowadays used…
Jan 28, 2025
4c7264b
[CLEAN] Added a log and made clearer the if conditions
Jan 29, 2025
c9a5195
[CORE] Set the NDK version using CMake templating
Jan 29, 2025
0a22646
[FIX] Fixed various problems related to the use of the visp bundle in…
Jan 29, 2025
b9ffb6e
[CORE] Gradle-based Android compilation run the javadoc command.
Jan 30, 2025
6148b56
[CORE] Copy doc compiled by gradle in the install directory
Jan 30, 2025
d845471
Merge branch 'master' into fix_android
Feb 5, 2025
cfbc615
Merge branch 'master' into fix_android
Feb 6, 2025
1c68f00
[CLEAN] Removed useless file
Feb 6, 2025
e8b5031
[FIX] Changed tags name because they were longer than the authorized …
Feb 6, 2025
c904b78
[WIP] Added an example of Android app. The folloing things are missing:
Feb 10, 2025
879bab4
[CORE] Create separate folders for the compilation results for the di…
Feb 11, 2025
c7b9d20
[CORE] Copying ViSP libs in the jniLibs folder to be able to run the …
Feb 11, 2025
2a67006
[FIX] Fix libopenmp.so not found
Feb 11, 2025
d8d4f1d
Merge branch 'master' into fix_android
Feb 11, 2025
d4f8c88
[TUTORIAL][DOC][WIP] Added the troubleshoutings section for Android a…
Feb 12, 2025
68e7189
[CLEAN] Removed useless build.gradle in the installation directory an…
Feb 12, 2025
fa76aee
[TUTO][DOC] Edited the images to highlight the point of interest in t…
Feb 12, 2025
ce94072
[TUTORIAL][DOC] Updated doc of the old tutorial based on the new sample
Feb 12, 2025
faf0e4c
[TUTO][DOC] Added a sidenote concerning the new version of Android St…
Feb 12, 2025
669f236
[ANDROID][CORE] Additionnal CMake flags can be passed to the build_sd…
Feb 12, 2025
cea3d77
[CORE] Changed field separator for CMake additional variables to allo…
Feb 13, 2025
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
49 changes: 28 additions & 21 deletions cmake/android/ViSPDetectAndroidSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ set(__msg_BUILD_ANDROID_PROJECTS "Use BUILD_ANDROID_PROJECTS=OFF to prepare Andr

macro(vp_detect_android_sdk)
if(NOT DEFINED ANDROID_SDK)
if(DEFINED ANDROID_SDK AND EXISTS "${ANDROID_SDK}")
set(ANDROID_SDK "${ANDROID_SDK}" CACHE INTERNAL "Android SDK path")
elseif(DEFINED ANDROID_HOME AND EXISTS "${ANDROID_HOME}")
if(DEFINED ANDROID_HOME AND EXISTS "${ANDROID_HOME}")
set(ANDROID_SDK "${ANDROID_HOME}" CACHE INTERNAL "Android SDK path")
elseif(DEFINED ANDROID_SDK_ROOT AND EXISTS "${ANDROID_SDK_ROOT}")
set(ANDROID_SDK "${ANDROID_SDK_ROOT}" CACHE INTERNAL "Android SDK path")
Expand All @@ -39,10 +37,14 @@ macro(vp_detect_android_sdk_tools)
if(NOT DEFINED ANDROID_SDK_TOOLS)
if(DEFINED ANDROID_SDK AND EXISTS "${ANDROID_SDK}/tools")
set(ANDROID_SDK_TOOLS "${ANDROID_SDK}/tools" CACHE INTERNAL "Android SDK Tools path")
set(ANDROID_SDK_TOOLS_TYPE "LEGACY")
elseif(DEFINED ANDROID_SDK AND EXISTS "${ANDROID_SDK}/cmdline-tools/latest")
set(ANDROID_SDK_TOOLS "${ANDROID_SDK}/cmdline-tools/latest" CACHE INTERNAL "Android SDK Tools path")
set(ANDROID_SDK_TOOLS_TYPE "CMDLINE")
else()
message(FATAL_ERROR "Android SDK Tools: can't automatically find Android SDK Tools. Specify path via ANDROID_SDK_TOOLS variable")
endif()
endif()
if(NOT DEFINED ANDROID_SDK_TOOLS)
message(FATAL_ERROR "Android SDK Tools: can't automatically find Android SDK Tools. Specify path via ANDROID_SDK_TOOLS variable")
message(STATUS "ANDROID_SDK_TOOLS_TYPE is ${ANDROID_SDK_TOOLS_TYPE}")
endif()
if(NOT EXISTS "${ANDROID_SDK_TOOLS}")
message(FATAL_ERROR "Android SDK Tools: specified path doesn't exist: ${ANDROID_SDK_TOOLS}")
Expand Down Expand Up @@ -159,21 +161,26 @@ if(BUILD_ANDROID_PROJECTS)
"${__msg_BUILD_ANDROID_PROJECTS}")
endif()

if(NOT ANDROID_SDK_TOOLS_VERSION VERSION_LESS 25.3.0)
message(STATUS "Android SDK Tools: Ant (Eclipse) builds are NOT supported by Android SDK")
vp_update(ANDROID_PROJECTS_SUPPORT_ANT OFF)
if(NOT ANDROID_SDK_BUILD_TOOLS_VERSION VERSION_LESS 26.0.2)
# https://developer.android.com/studio/releases/gradle-plugin.html
message(STATUS "Android SDK Build Tools: Gradle 3.0.0+ builds support is available")
vp_update(ANDROID_PROJECTS_SUPPORT_GRADLE ON)
endif()
else()
include(${CMAKE_CURRENT_LIST_DIR}/../VISPDetectApacheAnt.cmake)
if(ANT_EXECUTABLE AND NOT ANT_VERSION VERSION_LESS 1.7)
message(STATUS "Android SDK Tools: Ant (Eclipse) builds are supported")
vp_update(ANDROID_PROJECTS_SUPPORT_ANT ON)
if(ANDROID_SDK_TOOLS_TYPE STREQUAL "LEGACY")
if(NOT ANDROID_SDK_TOOLS_VERSION VERSION_LESS 25.3.0)
message(STATUS "Android SDK Tools: Ant (Eclipse) builds are NOT supported by Android SDK")
vp_update(ANDROID_PROJECTS_SUPPORT_ANT OFF)
if(NOT ANDROID_SDK_BUILD_TOOLS_VERSION VERSION_LESS 26.0.2)
# https://developer.android.com/studio/releases/gradle-plugin.html
message(STATUS "Android SDK Build Tools: Gradle 3.0.0+ builds support is available")
vp_update(ANDROID_PROJECTS_SUPPORT_GRADLE ON)
endif()
else()
include(${CMAKE_CURRENT_LIST_DIR}/../VISPDetectApacheAnt.cmake)
if(ANT_EXECUTABLE AND NOT ANT_VERSION VERSION_LESS 1.7)
message(STATUS "Android SDK Tools: Ant (Eclipse) builds are supported")
vp_update(ANDROID_PROJECTS_SUPPORT_ANT ON)
endif()
endif()
endif()
elseif(ANDROID_SDK_TOOLS_TYPE STREQUAL "CMDLINE")
message(STATUS "Android SDK Command-Line Build Tools: Gradle 3.0.0+ builds support is available")
vp_update(ANDROID_PROJECTS_SUPPORT_GRADLE ON)
endif(ANDROID_SDK_TOOLS_TYPE)

if(NOT DEFINED ANDROID_PROJECTS_BUILD_TYPE)
if(ANDROID_PROJECTS_SUPPORT_ANT)
Expand All @@ -184,7 +191,7 @@ if(BUILD_ANDROID_PROJECTS)
message(FATAL_ERROR "Android SDK: Can't build Android projects as requested by BUILD_ANDROID_PROJECTS=ON variable.\n"
"${__msg_BUILD_ANDROID_PROJECTS}")
endif()
endif()
endif(ANDROID_PROJECTS_BUILD_TYPE)

if(ANDROID_PROJECTS_BUILD_TYPE STREQUAL "ANT")
message(STATUS "Android SDK Tools: Prepare Android projects for using Ant build scripts (deprecated)")
Expand Down
57 changes: 31 additions & 26 deletions cmake/android/android_gradle_projects.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ message(STATUS "Android Gradle Plugin version: ${ANDROID_GRADLE_PLUGIN_VERSION}"
set(GRADLE_VERSION "5.6.4" CACHE STRING "Gradle version")
message(STATUS "Gradle version: ${GRADLE_VERSION}")

set(ANDROID_COMPILE_SDK_VERSION "26" CACHE STRING "Android compileSdkVersion")
set(ANDROID_COMPILE_SDK_VERSION "33" CACHE STRING "Android compileSdkVersion")
set(ANDROID_MIN_SDK_VERSION "21" CACHE STRING "Android minSdkVersion")
set(ANDROID_TARGET_SDK_VERSION "26" CACHE STRING "Android minSdkVersion")
set(ANDROID_TARGET_SDK_VERSION "33" CACHE STRING "Android target Sdk Version")

set(ANDROID_BUILD_BASE_DIR "${VISP_BINARY_DIR}/visp_android" CACHE INTERNAL "")
set(ANDROID_TMP_INSTALL_BASE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/install/visp_android")
Expand All @@ -30,16 +30,14 @@ if(NOT INSTALL_CREATE_DISTRIB)
set(ANDROID_INSTALL_ABI_FILTER "${ANDROID_BUILD_ABI_FILTER}")
endif()

file(WRITE "${VISP_BINARY_DIR}/root_android.txt" "${ANDROID_BUILD_BASE_DIR}")

# BUG: Ninja generator generates broken targets with ANDROID_ABI_FILTER name (CMake 3.11.2)
#set(__spaces " ")
#string(REPLACE "\n" "\n${__spaces}" ANDROID_ABI_FILTER "${__spaces}${ANDROID_BUILD_ABI_FILTER}")
#string(REPLACE REGEX "[ ]+$" "" ANDROID_ABI_FILTER "${ANDROID_ABI_FILTER}")
set(ANDROID_ABI_FILTER "${ANDROID_BUILD_ABI_FILTER}")
configure_file("${VISP_SOURCE_DIR}/samples/android/build.gradle.in" "${ANDROID_BUILD_BASE_DIR}/build.gradle" @ONLY)

set(ANDROID_ABI_FILTER "${ANDROID_INSTALL_ABI_FILTER}")
configure_file("${VISP_SOURCE_DIR}/samples/android/build.gradle.in" "${ANDROID_TMP_INSTALL_BASE_DIR}/${ANDROID_INSTALL_SAMPLES_DIR}/build.gradle" @ONLY)
install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/${ANDROID_INSTALL_SAMPLES_DIR}/build.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}" COMPONENT samples)

configure_file("${VISP_SOURCE_DIR}/platforms/android/gradle-wrapper/gradle/wrapper/gradle-wrapper.properties.in" "${ANDROID_BUILD_BASE_DIR}/gradle/wrapper/gradle-wrapper.properties" @ONLY)
install(FILES "${ANDROID_BUILD_BASE_DIR}/gradle/wrapper/gradle-wrapper.properties" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/gradle/wrapper" COMPONENT samples)
Expand All @@ -65,20 +63,8 @@ foreach(fname ${GRADLE_WRAPPER_FILES})
install(FILES "${VISP_SOURCE_DIR}/platforms/android/gradle-wrapper/${fname}" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples ${__permissions})
endforeach()

file(WRITE "${ANDROID_BUILD_BASE_DIR}/settings.gradle" "
include ':visp'
")

file(WRITE "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" "
rootProject.name = 'visp_samples'

def vispsdk='../'
//def vispsdk='/<path to ViSP-android-sdk>'
//println vispsdk
include ':visp'
project(':visp').projectDir = new File(vispsdk + '/sdk')
")

file(WRITE "${ANDROID_BUILD_BASE_DIR}/local.properties" "sdk.dir=${ANDROID_SDK}")
file(WRITE "${ANDROID_TMP_INSTALL_BASE_DIR}/local.properties" "sdk.dir=${ANDROID_SDK}")

macro(add_android_project target path)
get_filename_component(__dir "${path}" NAME)
Expand Down Expand Up @@ -107,8 +93,29 @@ macro(add_android_project target path)
configure_file("${path}/build.gradle.in" "${ANDROID_BUILD_BASE_DIR}/${__dir}/build.gradle" @ONLY)

file(APPEND "${ANDROID_BUILD_BASE_DIR}/settings.gradle" "
include ':${__dir}'
")
pluginManagement {
repositories {
google {
content {
includeGroupByRegex(\"com\\\\.android.*\")
includeGroupByRegex(\"com\\\\.google.*\")
includeGroupByRegex(\"androidx.*\")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

include ':${__dir}'
")

if (BUILD_ANDROID_EXAMPLES)
# build apk
Expand Down Expand Up @@ -160,9 +167,7 @@ include ':${__dir}'
install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/${__dir}/build.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}/${__dir}" COMPONENT samples)

file(APPEND "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" "
include ':${__dir}'
")
include ':${__dir}'
")

endmacro()

install(FILES "${ANDROID_TMP_INSTALL_BASE_DIR}/settings.gradle" DESTINATION "${ANDROID_INSTALL_SAMPLES_DIR}" COMPONENT samples)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading