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

Could not make sample Android Projects work #217

Open
bekleyis95 opened this issue Jun 7, 2022 · 0 comments
Open

Could not make sample Android Projects work #217

bekleyis95 opened this issue Jun 7, 2022 · 0 comments

Comments

@bekleyis95
Copy link

Hello, I am trying to use this repo but I could not make it work at all. I am using Ubuntu 20.04 and ROS2 Galactic. Installation instructions did not work for me but after some long alterations of the instructions I finally made it work. Here is what I did:

Java ROS instalation did not work for me, it was giving this error:

ModuleNotFoundError: No module named 'ament_package' CMake Error at /opt/ros/galactic/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message): execute_process(/root/anaconda3/bin/python3 /opt/ros/galactic/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py /home/roboy/ros2_java_ws/build/ament_java_resources/ament_cmake_package_templates/templates.cmake) returned error code 1 Call Stack (most recent call first): /opt/ros/galactic/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include) /opt/ros/galactic/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package) /opt/ros/galactic/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include) CMakeLists.txt:5 (find_package)
But since the Android instructions already contained the similar modules I thought I can only follow the Android instructions. But it was problematic as well.

First spd_logging was causing errors and after some digging in the Issues sections I read that this can be ignored. So I add rcl_logging_spdlog to --packages_ignore and I also needed to add -DBUILD_TESTING=OFF to the colcon build script, here is the final script that I used:

sudo colcon build \ --packages-ignore cyclonedds rcl_logging_log4cxx \ rosidl_generator_py rcl_logging_spdlog \ --packages-up-to rcljava \ --cmake-args \ -DPYTHON_EXECUTABLE=${PYTHON3_EXEC} \ -DPYTHON_LIBRARY=${PYTHON3_LIBRARY} \ -DPYTHON_INCLUDE_DIR=${PYTHON3_INCLUDE_DIR} \ -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \ -DANDROID_FUNCTION_LEVEL_LINKING=OFF \ -DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \ -DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME} \ -DANDROID_STL=c++_shared \ -DANDROID_ABI=${ANDROID_ABI} \ -DANDROID_NDK=${ANDROID_NDK} \ -DTHIRDPARTY=ON \ -DCOMPILE_EXAMPLES=OFF \ -DCMAKE_FIND_ROOT_PATH="${PWD}/install" \ -DBUILD_TESTING=OFF

Secondly #include <tinyxml2.h> was causing errors and after I changed these statements to absolute paths like #include "/home/roboy/ros2_android_ws/src/eProsima/Fast-DDS/thirdparty/tinyxml2/tinyxml2.h" it worked.

Thirdly, IPFinder.cpp file was causing troubles so I needed to comment out the parts that includes getifaddrs and freeifaddrs functions.

Lastly as the it is suggested in here I changed this part
if(NOT "${RCL_LOGGING_IMPLEMENTATION}" STREQUAL "") set(_logging_implementation "${RCL_LOGGING_IMPLEMENTATION}") elseif(NOT "$ENV{RCL_LOGGING_IMPLEMENTATION}" STREQUAL "") set(_logging_implementation "$ENV{RCL_LOGGING_IMPLEMENTATION}") else() set(_logging_implementation rcl_logging_spdlog) endif()
to
set(_logging_implementation rcl_logging_noop)

After all this I was finally able to colcon build but the sample projects was unable to gradle build and when I tried to implement the project in my example app, I could not include the necessary imports such as BaseComposableNode class, Android Studio did not recognize them. I tried frankly everything and now I think maybe something missing in the instructions for Android Studio to recognize these imports.

Any help is appreciated. Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant