Skip to content
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
73 changes: 70 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,80 @@ jobs:
steps:
- name: Install Java
run: |
sudo apt update -qq
sudo apt install -y default-jdk
sudo apt-get update -qq
sudo apt-get install -y default-jdk gradle
- uses: actions/checkout@v2
- uses: ros-tooling/setup-ros@0.0.14
with:
required-ros-distributions: dashing
- uses: ros-tooling/action-ros-ci@8d58122
with:
package-name: rosidl_generator_java rcljava_common rcljava
source-ros-binary-installation: dashing
vcs-repo-file-url: https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_desktop.repos
vcs-repo-file-url: ${{ github.workspace }}/ros2_java_desktop.repos

build_android:
runs-on: ubuntu-18.04
steps:
- name: Install Java
run: |
sudo apt-get update -qq
sudo apt-get install -y default-jdk gradle
- uses: actions/checkout@v2
- name: Setup locale for ROS 2
run: |
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
- name: Setup sources for ROS 2
run: |
sudo apt-get update && sudo apt-get install -y curl gnupg2 lsb-release
curl -sL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
- name: Install ROS 2 dependencies
run: |
sudo apt-get update && sudo apt-get install -y python3-colcon-common-extensions python3-vcstool python3-lark-parser python3-dev
- name: Install colcon extensions for Gradle
run: |
sudo pip3 install git+git://github.com/colcon/colcon-gradle.git
sudo pip3 install git+git://github.com/colcon/colcon-ros-gradle.git
- name: Install Android NDK
run: |
curl -LO https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip
unzip android-ndk-r21d-linux-x86_64.zip
- name: Setup workspace with VCS repo file
run: |
mkdir -p ros2_java_ws/src
cd ros2_java_ws
curl -sL file://${{ github.workspace }}/ros2_java_android.repos | vcs import src
# Use checked out version of ros2_java
rm -rf src/ros2_java/ros2_java
ln --symbolic ${{ github.workspace }} src/ros2_java
- name: Build ros2_java for Android
run: |
export PYTHON3_EXEC="$( which python3 )"
export PYTHON3_LIBRARY="$( ${PYTHON3_EXEC} -c 'import os.path; from distutils import sysconfig; print(os.path.realpath(os.path.join(sysconfig.get_config_var("LIBPL"), sysconfig.get_config_var("LDLIBRARY"))))' )"
export PYTHON3_INCLUDE_DIR="$( ${PYTHON3_EXEC} -c 'from distutils import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))' )"
export ANDROID_ABI=armeabi-v7a
export ANDROID_NATIVE_API_LEVEL=android-21
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang
export ANDROID_NDK=${PWD}/android-ndk-r21d

cd ros2_java_ws
colcon build \
--packages-ignore cyclonedds rcl_logging_log4cxx rosidl_generator_py \
--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"
224 changes: 108 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
ROS2 for Java
=============
# ROS 2 Java client library

Build status
------------
### Build status

| Target | Status |
|----------|--------|
| **Ubuntu Xenial (OpenJDK)** | [![Build Status](http://vsts-matrix-badges.herokuapp.com/repos/ros2-java/ros2-java/1/branches/master/1)](https://dev.azure.com/ros2-java/ros2-java/_build?definitionId=1) |
| **Ubuntu Xenial (Android)** | [![Build Status](http://vsts-matrix-badges.herokuapp.com/repos/ros2-java/ros2-java/1/branches/master/2)](https://dev.azure.com/ros2-java/ros2-java/_build?definitionId=1) |
| Target | Status |
|-------------------------------------------|---------------|
| **ROS Dashing - Ubuntu Bionic (OpenJDK)** | ![Build Status](https://github.com/ros2-java/ros2_java/workflows/CI/badge.svg?branch=dashing) |

Introduction
------------
## Introduction

This is a set of projects (bindings, code generator, examples and more) that enables developers to write ROS2
This is a set of projects (bindings, code generator, examples and more) that enables developers to write ROS 2
applications for the JVM and Android.

Besides this repository itself, there's also:
- https://github.com/esteve/ament_java, which adds support for Gradle to Ament
- https://github.com/esteve/ament_gradle_plugin, a Gradle plugin that makes it easier to use ROS2 in Java and Android project. The Gradle plugin can be installed from Gradle Central https://plugins.gradle.org/plugin/org.ros2.tools.gradle
- https://github.com/esteve/ros2_java_examples, examples for the Java Runtime Environment
- https://github.com/esteve/ros2_android_examples, examples for Android
- https://github.com/ros2-java/ament_java, which adds support for Gradle to Ament
- https://github.com/ros2-java/ament_gradle_plugin, a Gradle plugin that makes it easier to use ROS 2 in Java and Android project. The Gradle plugin can be installed from Gradle Central https://plugins.gradle.org/plugin/org.ros2.tools.gradle
- https://github.com/ros2-java/ros2_java_examples, examples for the Java Runtime Environment
- https://github.com/ros2-java/ros2_android_examples, examples for Android

Is this Java only?
------------------
### Is this Java only?

No, any language that targets the JVM can be used to write ROS2 applications.
No, any language that targets the JVM can be used to write ROS 2 applications.

Including Android?
------------------
### Including Android?

Yep! Make sure to use Fast-RTPS as your DDS vendor and at least [this revision](https://github.com/eProsima/Fast-RTPS/commit/5301ef203d45528a083821c3ba582164d782360b).

Features
--------
### Features

The current set of features include:
- Generation of all builtin and complex ROS types, including arrays, strings, nested types, constants, etc.
Expand All @@ -41,76 +34,80 @@ The current set of features include:
- Clients and services
- Timers
- Composition (i.e. more than one node per process)
- Time handling (system and steady, ROS time not yet supported https://github.com/ros2/ros2/issues/350)
- Time handling (system and steady, ROS time not yet supported https://github.com/ros2-java/ros2_java/issues/122)
- Support for Android
- Parameters services and clients (both asynchronous and synchronous)

Sounds great, how can I try this out?
-------------------------------------
## Sounds great, how can I try this out?

### Install dependencies

> Note: While the following instructions use a Linux shell the same can be done on other platforms like Windows with slightly adjusted commands.
>
> For Windows and Mac, first follow the steps for installing prerequisites on the binary installation page: https://github.com/ros2/ros2/wiki/Installation
>
> Stop and return here when you reach the "Downloading ROS 2" section.

Download the ament repositories in a separate workspace:
1. [Install ROS 2](https://index.ros.org/doc/ros2/Installation).

1. Install Java and a JDK.

On Ubuntu, you can install OpenJDK with:

sudo apt install default-jdk

1. Install Gradle.
Make sure you have Gradle 3.2 (or later) installed.

*Ubuntu Bionic or later*

sudo apt install gradle

*macOS*

brew install gradle

Note: if run into compatibily issues between gradle 3.x and Java 9, try using Java 8,

brew tap caskroom/versions
brew cask install java8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.8.0.jdk/Contents/Home

*Windows*

choco install gradle

1. Install build tools:

sudo apt install curl python3-colcon-common-extensions python3-pip python3-vcstool

```
mkdir -p ament_ws/src
cd ament_ws
curl -skL https://raw.githubusercontent.com/esteve/ament_java/master/ament_java.repos -o ament_java.repos
vcs import src < ament_java.repos
src/ament/ament_tools/scripts/ament.py build --symlink-install --isolated
```
1. Install Gradle extensions for colcon:

> Note: On Windows, use `python src/ament/ament_tools/scripts/ament.py build`, as `*.py` scripts must be prefixed with `python`, `--symlink-install` is not supported due to a bug in Python symlinks, and `--isolated` creates paths that are too long.
> Additionally, you may need to call `call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"` if you have not run from a VS 2017 terminal.
python3 -m pip install -U git+https://github.com/colcon/colcon-gradle
python3 -m pip install --no-deps -U git+https://github.com/colcon/colcon-ros-gradle

We need to split the build process between Ament and the rest of `ros2_java` workspace so that the additional build type for Gradle projects is picked up by Ament.
### Download and Build ROS 2 Java for Desktop

Make sure you have Gradle 3.2 (or later) installed. Ubuntu 16.04 ships with Gradle 2.10, you can install a more recent version of Gradle from the following PPA:
1. Source your ROS 2 installation, for example:

```
$ sudo add-apt-repository ppa:cwchien/gradle
$ sudo apt install -y gradle
```
For OSX, use homebrew command to install gradle:
source /opt/ros/dashing/setup.bash

```
$ brew install gradle
```
1. Download the ROS 2 Java repositories into a workspace:

For OSX users, there some compatibily issues have been reported between gradle 3.x and Java 9. Currently only the combination of Gradle 3.x + Java 8 has been tested successfully. Make sure to use install and use Java 8 for the building process:
mkdir -p ros2_java_ws/src
cd ros2_java_ws
curl -skL https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_desktop.repos | vcs import src

```
$ brew tap caskroom/versions
$ brew cask install java8
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/1.8.0.jdk/Contents/Home
```
1. **Linux only** Install ROS dependencies:

> Note: On Windows, you may use `choco install -y gradle`
rosdep install --from-paths src -y -i --skip-keys "ament_tools"

The following sections deal with building the `ros2_java` codebase for the desktop Java runtime and for Android.
1. Build desktop packages:

Desktop
-------
colcon build --symlink-install

```
mkdir -p ros2_java_ws/src
cd ros2_java_ws
curl -skL https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_desktop.repos -o ros2_java_desktop.repos
vcs import src < ros2_java_desktop.repos
. ../ament_ws/install_isolated/local_setup.sh
ament build --symlink-install --isolated
```
*Note, on Windows we have to use `--merge-install`*

> On Windows, if you would like to use OpenSplice, call `call "C:\opensplice67\HDE\x86_64.win64\release.bat"` before building.
colcon build --merge-install

Now you can just run a bunch of examples, head over to https://github.com/esteve/ros2_java_examples for more information.

Android
-------
### Download and Build ROS 2 Java for Android
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer not to merge this PR until the Android instructions are complete, some of the users that use ros2-java use it only because of the Android support.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that this isn't making things worse for Android, it just isn't improving it either. So I'd still say we should merge this one (just so it doesn't linger), and then when somebody gets around to updating Android it would go on top of this.

Copy link
Member

@esteve esteve Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that this isn't making things worse for Android, it just isn't improving it either.

It definitely makes things worse for Android users, because they won't have a path for building ros2_java. Currently they can build ros2_java for Bouncy, but once master only works for Dashing, they won't have instructions for building ros2_java.

and then when somebody gets around to updating Android it would go on top of this.

The goal of ros2_java is to support JRE and Android, so any contribution must target both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely makes things worse for Android users, because they won't have a path for building ros2_java. Currently they can build ros2_java for Bouncy, but once master only works for Dashing, they won't have instructions for building ros2_java.

I guess my main point is that this PR targets the dashing branch, which already doesn't work for Android. So we can merge it onto the dashing branch; we just can't merge the dashing branch onto master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this raises a separate question about organization. I'd been working under the idea that we would maintain separate branches for each ROS distribution (like many other ROS packages). If users want to build on top of Bouncy, then they can refer to the bouncy branch.

To make it more clear for users, we could add a note near the top of the README referring them to the correct branch (with instructions) for their target distribution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that for our use-cases we don't have as strong an interest in Android, but I do think we should still support it. Before opening this PR I did try to compile rcljava for Android to update the instructions and add CI, but haven't had any success yet. I'm not sure what needs to change in the documentation (or code) to make the instructions work. Unfortunately, since it's not a priority it's difficult for me to spend more time on it at the moment (hence the TODO). We can wait to merge this until we figure it out, but I thought it would be nicer to get the current changes in as an incremental improvement.

Regarding branches for each distro, I guess it's a matter of opinion. I think it makes maintenance and development a lot easier. Unless we only want to support the latest distro, we're bound to make changes to the default branch that breaks compatibility with older distros. If we want to maintain compatibility on a single branch, then we have to do things like "ifdef" around code blocks, which seems less pleasant (IMO) than maintaining distro-specific branches. I've tried to structure code changes such that dashing will remain compatible with Dashing and then I'd like to cherry-pick changes I have on my dev branch for Foxy compatibility to master (since the changes to Foxy are not compatibility with Dashing). I'm open to other strategies for maintaining compatibility between distros. I shouldn't have presumed that we'd use this branching method, sorry about that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, my qualm is that OSRF has its own agenda regarding ros2-java, which seems to be aligned for the most part with the goals I have when I started this project, except for the Android stuff. But this is not an OSRF project, so all contributors are treated equally, no matter who their employer is.

Sure. That only makes sense; every contributor has their own agenda for contributing to the project.

To be honest, I'm less than enthusiastic about OSRF seemingly trying to set the goals for ros2-java, hence why I prefer to keep this project separate from them. I feel strongly about supporting Android, and any contribution must take Android into account, but you guys seem very keen on not updating ros2-java for Android in your contributions, whether code or documentation. Frankly, updating the README with instructions for Android requires much less work than setting up different branches for each distro.

We are just setting the goals for the things that we are interested in. As you can probably tell, we aren't much interested in Android. I think the disconnect we currently have is that there are 2 main branches of development:

  • Bouncy with Android support
  • Dashing and later without Android support

Jacob and I are mostly interested in the latter; you are mostly interested in the former.

It's not that we don't care at all about the Android goal of the project, but it isn't clear to me how to keep that support working. Since it isn't our main target, its hard to justify spending a lot of time setting it up.

There are several ways to rectify the disconnect:

  1. Provide a docker image to automatically build/test Android support
  2. Keep developing on separate branches, one for Android, one for other things
  3. Fork the repository

There may be others.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are just setting the goals for the things that we are interested in.

OSRF can not set the goals for the project, basically because they are not the owners of ros2_java

It's not that we don't care at all about the Android goal of the project, but it isn't clear to me how to keep that support working. Since it isn't our main target, its hard to justify spending a lot of time setting it up.

I don't think it's that much time. I'm more than happy to help you if you have problems with setting it up

I think the disconnect we currently have is that there are 2 main branches of development:

Bouncy with Android support
Dashing and later without Android support

Maintaining multiple branches requires a lot of effort, which in this case is completely unnecessary because there's nothing in the code that prevents both platforms from being supported. My goal is to only have one branch, it's much simpler that way

Keep developing on separate branches, one for Android, one for other things

The Android code is isolated in other layers in ROS 2, there's nothing in ros2_java, either in master or the dashing branch that prevents it from running on Android, only the instructions need to be updated.

Fork the repository

Whoa, the nuclear option just because you don't want to update a README. Frankly, not a big fan of this level of confrontation

There may be others.

When contributing to a project you are not even a committer, it's good etiquette to try to cooperate at least, at least from my experience

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed changes to the instructions that I've tried so far and opened a PR targeting this branch #125

I can continue to chip away at it in some free time, but any insights would be greatly appreciated 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've merged #125 here, containing instructions for Android (and CI!) (a3fa46d)


The Android setup is slightly more complex, you'll need the SDK and NDK installed, and an Android device where you can run the examples.

Expand All @@ -122,48 +119,43 @@ We'll also need to have the [Android SDK](https://developer.android.com/studio/#

Although the `ros2_java_android.repos` file contains all the repositories for the Android bindings to compile, we'll have to disable certain packages (`python_cmake_module`, `rosidl_generator_py`, `test_msgs`) that are included the repositories and that we either don't need or can't cross-compile properly (e.g. the Python generator)

```
# define paths
ROOT_DIR = ${HOME}
AMENT_WORKSPACE=${ROOT_DIR}/ament_ws
ROS2_ANDROID_WORKSPACE=${ROOT_DIR}/ros2_android_ws

# pull and build ament
mkdir -p ${AMENT_WORKSPACE}/src
cd ${AMENT_WORKSPACE}
wget https://raw.githubusercontent.com/esteve/ament_java/master/ament_java.repos
vcs import ${AMENT_WORKSPACE}/src < ament_java.repos
src/ament/ament_tools/scripts/ament.py build --symlink-install --isolated

# android build configuration
export PYTHON3_EXEC="$( which python3 )"
export ANDROID_ABI=armeabi-v7a
export ANDROID_NATIVE_API_LEVEL=android-21
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang

# pull and build ros2 for android
mkdir -p ${ROS2_ANDROID_WORKSPACE}/src
cd ${ROS2_ANDROID_WORKSPACE}
wget https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_android.repos
vcs import ${ROS2_ANDROID_WORKSPACE}/src < ros2_java_android.repos
source ${AMENT_WORKSPACE}/install_isolated/local_setup.sh
ament build --isolated --skip-packages test_msgs \
--cmake-args \
-DPYTHON_EXECUTABLE=${PYTHON3_EXEC} \
-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=gnustl_shared \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_NDK=${ANDROID_NDK} \
-DTHIRDPARTY=ON \
-DCOMPILE_EXAMPLES=OFF \
-DCMAKE_FIND_ROOT_PATH="$AMENT_WORKSPACE/install_isolated;$ROS2_ANDROID_WORKSPACE/install_isolated" \
-- \
--parallel \
--ament-gradle-args \
-Pament.android_stl=gnustl_shared -Pament.android_abi=$ANDROID_ABI -Pament.android_ndk=$ANDROID_NDK --
```

You can find more information about the Android examples at https://github.com/esteve/ros2_android_examples
1. Download the [Android NDK](https://developer.android.com/ndk/downloads/index.html) and set the environment variable `ANDROID_NDK` to the path where it is extracted.

1. Download the [Android SDK](https://developer.android.com/studio/#downloads) and set the environment variable `ANDROID_HOME` to the path where it is extracted.

1. Clone ROS 2 and ROS 2 Java source code:

mkdir -p $HOME/ros2_android_ws/src
cd $HOME/ros2_android_ws
curl https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_android.repos | vcs import src

1. Set Android build configuration:

export PYTHON3_EXEC="$( which python3 )"
export PYTHON3_LIBRARY="$( ${PYTHON3_EXEC} -c 'import os.path; from distutils import sysconfig; print(os.path.realpath(os.path.join(sysconfig.get_config_var("LIBPL"), sysconfig.get_config_var("LDLIBRARY"))))' )"
export PYTHON3_INCLUDE_DIR="$( ${PYTHON3_EXEC} -c 'from distutils import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))' )"
export ANDROID_ABI=armeabi-v7a
export ANDROID_NATIVE_API_LEVEL=android-21
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang

1. Build (skipping packages that we don't need or can't cross-compile):

colcon build \
--packages-ignore cyclonedds rcl_logging_log4cxx rosidl_generator_py \
--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"

You can find more information about the Android examples at https://github.com/ros2-java/ros2_android_examples
2 changes: 0 additions & 2 deletions rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

import java.lang.ref.WeakReference;

import java.lang.reflect.Method;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down
14 changes: 13 additions & 1 deletion rcljava/src/test/java/org/ros2/rcljava/client/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Test;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.time.Duration;

import java.util.Arrays;
Expand All @@ -46,7 +47,18 @@ public class ClientTest {
@BeforeClass
public static void setupOnce() throws Exception {
RCLJava.rclJavaInit();
org.apache.log4j.BasicConfigurator.configure();
try
{
// Configure log4j. Doing this dynamically so that Android does not complain about missing
// the log4j JARs, SLF4J uses Android's native logging mechanism instead.
Class c = Class.forName("org.apache.log4j.BasicConfigurator");
Method m = c.getDeclaredMethod("configure", (Class<?>[]) null);
Object o = m.invoke(null, (Object[]) null);
}
catch (Exception e)
{
e.printStackTrace();
}
}

public class TestClientConsumer implements TriConsumer<RMWRequestId,
Expand Down
Loading