I can't build for android following the README instructions. I have the following script:
#!/bin/bash
set -e
AMENT_WS_INSTALL=$HOME/code/ament_java/install_isolated
ANDROID_NDK_ROOT=$HOME/Android/Ndk/android-ndk-r17
ROS2_INSTALL=$HOME/ros2_android/install_isolated
source $AMENT_WS_INSTALL/local_setup.bash
ament build --isolated --cmake-args \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
-DANDROID_FUNCTION_LEVEL_LINKING=OFF \
-DANDROID_NATIVE_API_LEVEL=android-21 \
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang \
-DANDROID_STL=gnustl_shared \
-DANDROID_ABI=armeabi-v7a \
-DANDROID_NDK=$ANDROID_NDK_ROOT \
-DTHIRDPARTY=ON \
-DCOMPILE_EXAMPLES=OFF \
-DCMAKE_FIND_ROOT_PATH="$AMENT_WS_INSTALL;$ROS2_INSTALL" \
-- \
--parallel \
--ament-gradle-args \
-Pament.android_stl=gnustl_shared -Pament.android_abi=armeabi-v7a -Pament.android_ndk=$ANDROID_NDK_ROOT --
The first time running this script it finishes fairly quickly with:
...
-- Installing: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/cmake/poco_vendorConfig.cmake
-- Installing: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/cmake/poco_vendorConfig-version.cmake
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/environment/ament_prefix_path.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/environment/path.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/environment/library_path.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/local_setup.bash
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/local_setup.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/share/poco_vendor/local_setup.zsh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/local_setup.bash
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/local_setup.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/local_setup.zsh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/setup.bash
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/setup.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/setup.zsh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/poco_vendor/_order_packages.py
Failed packages: rcutils
The second time it is run, the build fails trying to link fastrtps with the following error:
...
[ 38%] Building C object src/cpp/CMakeFiles/fastrtps.dir/__/__/thirdparty/android-ifaddrs/ifaddrs.c.o
72 warnings generated.
73 warnings generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
[ 39%] Linking CXX shared library libfastrtps.so
/home/johnmark/Android/Ndk/android-ndk-r17/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lfastcdr
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
src/cpp/CMakeFiles/fastrtps.dir/build.make:1403: recipe for target 'src/cpp/libfastrtps.so' failed
make[2]: *** [src/cpp/libfastrtps.so] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/cpp/CMakeFiles/fastrtps.dir/all' failed
make[1]: *** [src/cpp/CMakeFiles/fastrtps.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
<== Command '. /home/johnmark/code/ros2_android/build_isolated/fastrtps/cmake__build.sh && /usr/bin/make -j8 -l8' failed in '/home/johnmark/code/ros2_android/build_isolated/fastrtps' with exit code '2'
Failed packages: rcutils
The third time I get:
...
-- Up-to-date: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/share/rosidl_parser/package.xml
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/local_setup.bash
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/local_setup.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/local_setup.zsh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/setup.bash
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/setup.sh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/setup.zsh
-- [ament] Deploying: /home/johnmark/code/ros2_android/install_isolated/rosidl_parser/_order_packages.py
CMake Error at CMakeLists.txt:7 (find_package):
By not providing "Findament_cmake_export_jars.cmake" in CMAKE_MODULE_PATH
this project has asked CMake to find a package configuration file provided
by "ament_cmake_export_jars", but CMake did not find one.
Could not find a package configuration file provided by
"ament_cmake_export_jars" with any of the following names:
ament_cmake_export_jarsConfig.cmake
ament_cmake_export_jars-config.cmake
Add the installation prefix of "ament_cmake_export_jars" to
CMAKE_PREFIX_PATH or set "ament_cmake_export_jars_DIR" to a directory
containing one of the above files. If "ament_cmake_export_jars" provides a
separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
See also "/home/johnmark/code/ros2_android/build_isolated/rcljava_common/CMakeFiles/CMakeOutput.log".
<== Command '. /home/johnmark/code/ros2_android/build_isolated/rcljava_common/cmake__build.sh && /usr/local/bin/cmake -DBUILD_TESTING=0 -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_TOOLCHAIN_FILE=/home/johnmark/Android/Ndk/android-ndk-r17/build/cmake/android.toolchain.cmake -DANDROID_FUNCTION_LEVEL_LINKING=OFF -DANDROID_NATIVE_API_LEVEL=android-21 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang -DANDROID_STL=gnustl_shared -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=/home/johnmark/Android/Ndk/android-ndk-r17 -DTHIRDPARTY=ON -DCOMPILE_EXAMPLES=OFF '-DCMAKE_FIND_ROOT_PATH=/home/johnmark/code/ament_java/install_isolated;/home/johnmark/ros2_android/install_isolated' -DCMAKE_INSTALL_PREFIX=/home/johnmark/code/ros2_android/install_isolated/rcljava_common /home/johnmark/code/ros2_android/src/ros2_java/ros2_java/rcljava_common' failed in '/home/johnmark/code/ros2_android/build_isolated/rcljava_common' with exit code '1'
Failed packages: rcutils
Building for desktop Java works fine.
Edit: I thought the problem was trying to compile with examples on, but even without examples it fails
I can't build for android following the README instructions. I have the following script:
The first time running this script it finishes fairly quickly with:
The second time it is run, the build fails trying to link fastrtps with the following error:
The third time I get:
Building for desktop Java works fine.
Edit: I thought the problem was trying to compile with examples on, but even without examples it fails