aldebaran / libqi-java

QiMessaging Java bindings
Other
14 stars 13 forks source link

Specified toolchain "arm-linux-androideabi-4.9" is missing in your NDK or broken #7

Open Michdo93 opened 2 years ago

Michdo93 commented 2 years ago

Hi,

I tried to use the toolchain for android-arm but I got this error:

Using toolchain: android-arm
* (1/1) Configuring qimessaging-jni
CMake Error at /home/nao/.local/share/qi/toolchains/android-arm/ndk/toolchain.cmake:773 (message):
  Specified toolchain "arm-linux-androideabi-4.9" is missing in your NDK or
  broken.  Please verify that your NDK is working or select another compiler
  toolchain.

  To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one
  of the following values:

    * arm-linux-androideabi-4.4.3
    * arm-linux-androideabi-4.6
    * arm-linux-androideabi-4.7
    * arm-linux-androideabi-clang3.1
    * arm-linux-androideabi-clang3.2
    * mipsel-linux-android-4.4.3
    * mipsel-linux-android-4.6
    * mipsel-linux-android-4.7
    * mipsel-linux-android-clang3.1
    * mipsel-linux-android-clang3.2
    * x86-4.4.3
    * x86-4.6
    * x86-4.7
    * x86-clang3.1
    * x86-clang3.2

Call Stack (most recent call first):
  /home/nao/.local/share/qi/toolchains/android-arm/toolchain-android-arm.cmake:5 (include)
  /usr/share/cmake-3.5/Modules/CMakeDetermineSystem.cmake:98 (include)
  CMakeLists.txt:2 (project)

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

So, one step after another...

I created a Ubuntu 16.04 virtual machine. I installed Python 2.7 and pip for Python 2.7. Then I installed the Python SDK. After that I installed the C++ SDK and qibuild. Then I downloaded the Java SDK and the JavaScript SDK. With all this I have written basic examples for a Pepper with NAOqi 2.5. Then I tried to use the Java SDK in my Android Project. Sadly this does not work. After that I have seen in libqi-java that there could be a possibility.

java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~16.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)

I installed Android Studio by using the Ubuntu Software Center. At first I have installed NDK by going to Tools --> SDK Manager --> SDK Tools. But sadly this was NDK 24.x. Then I uninstalled this version. The oldest version I can find inside SDK Tools was 16.x. I then downloaded android-ndk-r8e. I unzipped it to the location where Android Studio normally would install Android NDK.

For better understandig... This are my enviroment variables:

export PYTHONPATH=$PYTHONPATH:/home/nao/naoqi/pynaoqi-python2.7-2.5.7.1-linux64/lib/python2.7/site-packages:/home/nao/naoqi/pynaoqi-python2.7-2.5.7.1-linux64/lib/python2.7/dist-packages:/home/nao/.local/lib/python2.7/site-packages

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/nao/.local/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin:/home/nao/Android/Sdk:/home/nao/Android/Sdk/ndk-bundle"
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ROS_HOSTNAME="$(hostname -f)"
ROS_MASTER_URI=http://$ROS_HOSTNAME:11311
ROS_IP="$(hostname -I | awk '{print $1;}')"
ANDROID_HOME=/home/nao/Android/Sdk
ANDROID_NDK_HOME=/home/nao/Android/Sdk/ndk-bundle
ANDROID_NDK_ROOT=/home/nao/Android/Sdk/ndk-bundle

You have written in your README.md that ANDROID_NDK_HOME should point to /path/to/android-ndk-r8e. If I run qibuild the ANDROID_NDK_ROOT should point to that location. I fixed it. But inside of the android-ndk-r8e there is no arm-linux-androideabi-4.9. I then edited /home/nao/.local/share/qi/toolchains/android-arm/ndk/toolchain.cmake by adding:

set(ANDROID_TOOLCHAIN_NAME "arm-linux-androideabi-4.4.3")

After that I run into the next error:

* (1/1) Configuring qimessaging-jni
-- Adjusting Android API level 'android-17' to 'android-14'
-- Using qibuild 3.17
-- Library: qimessagingjni
CMake Error at /home/nao/.local/share/cmake/qibuild/internal/uselib.cmake:80 (find_package):
  By not providing "FindQI.cmake" in CMAKE_MODULE_PATH this project has asked
  CMake to find a package configuration file provided by "QI", but CMake did
  not find one.

  Could not find a package configuration file provided by "QI" with any of
  the following names:

    QIConfig.cmake
    qi-config.cmake

  Add the installation prefix of "QI" to CMAKE_PREFIX_PATH or set "QI_DIR" to
  a directory containing one of the above files.  If "QI" provides a separate
  development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  /home/nao/.local/share/cmake/qibuild/internal/uselib.cmake:197 (_qi_use_lib_get_deps)
  /home/nao/.local/share/cmake/qibuild/stage.cmake:247 (_qi_use_lib_internal)
  /home/nao/.local/share/cmake/qibuild/target.cmake:277 (qi_use_lib)
  CMakeLists.txt:59 (qi_create_lib)

-- Configuring incomplete, errors occurred!
See also "/home/nao/worktree/libqi-java/jni/build-android-arm/CMakeFiles/CMakeOutput.log".

I can locate it:

locate qi-config.cmake
/home/nao/naoqi/ctc-linux64-atom-2.5.10.7/libqi/share/cmake/qi/qi-config.cmake
/home/nao/naoqi/naoqi-sdk-2.5.7.1-linux64/share/cmake/qi/qi-config.cmake

Maybe you have a solution for this issue.

What I have done before was doing following steps:

qitoolchain create --feed-name android-arm android-arm https://github.com/aldebaran/toolchains.git
qitoolchain create --feed-name android-x86 android-x86 https://github.com/aldebaran/toolchains.git
qitoolchain create --feed-name android-x86_64 android-x86_64 https://github.com/aldebaran/toolchains.git
qitoolchain create --feed-name linux64 linux64 https://github.com/aldebaran/toolchains.git
qitoolchain create --feed-name mac64 mac64 https://github.com/aldebaran/toolchains.git
qitoolchain create --feed-name win32-vs2013 win32-vs2013 https://github.com/aldebaran/toolchains.git

qitoolchain list
Known toolchains:
* android-arm
* android-x86
* android-x86_64
* cross-atom
* linux64
* mac64
* mytoolchain
* win32-vs2013

qibuild add-config android-arm -t android-arm
qibuild add-config android-x86 -t android-x86
qibuild add-config android-x86_64 -t android-x86_64
qibuild add-config linux64 -t linux64
qibuild add-config mac64 -t mac64
qibuild add-config win32-vs2013 -t win32-vs2013

The next step would not work:

mkdir -p ~/work/aldebaran
cd ~/work/aldebaran
qisrc init git@github.com:aldebaran/manifest.git

You can find this issue here:

https://github.com/aldebaran/manifest/issues/2

A workaround is to clone it from github directly.

I also does not use ~/work. I will use ~/worktree. Because this was described so in the installation guide for the C++ SDK.

The next steps would be:

cd /home/nao/worktree/libqi-java/jni
qibuild configure --release -c android-arm
qibuild make -j4 -c android-arm
mkdir -p ../qimessaging/lib/armeabi-v7a
mkdir -p /tmp/libqi-java/android-arm/
qibuild install --runtime -c android-arm

cd /tmp/libqi-java/android-arm/

for file in $(find -name [*](https://github.com/aldebaran/libqi-java#id1).so) do
    cp $file ~/work/aldebaran/sdk/libqi-java/qimessaging/lib/armeabi-v7a
done

cd ~/work/aldebaran/sdk/libqi-java
rm -rf /tmp/libqi-java/android-arm/
cp -f jni/build-android-arm/sdk/lib/libgnustl_shared.so qimessaging/lib/armeabi-v7a
cd qimessaging
mvn install -DskipTests=true # use -f pom-android.xml version=$(cat pom-android.xml | grep -oPm1 "(?<=<version>)[^<]+")
zip -r target/libqi-java-$version.jar lib/

Perhaps in the further procedure would be even more errors that I become aware of.

Thanks in advance.

victorpaleologue commented 2 years ago

Please also share the command you typed to get the first error message.

Michdo93 commented 2 years ago

It was the same command. Sorry, I have not said when the error occurs. After I run qibuild configure --release -c android-arm the error above occurs.

Michdo93 commented 2 years ago

To make it clear. The error arm-linux-androideabi-4.9 is broken I got after running qibuild configure --release -c android-arm. Then I added set(ANDROID_TOOLCHAIN_NAME "arm-linux-androideabi-4.4.3") to /home/nao/.local/share/qi/toolchains/android-arm/ndk/toolchain.cmake.

Then I got an error that QI_DIR is missing if I run it again. After that that ICU_DIR is missing and after that that SYSTEMD_DIR is missing.

This could be fixed by adding following line to /etc/environment:

QI_DIR=/home/nao/naoqi/ctc-linux64-atom-2.5.10.7/libqi/share/cmake
ICU_DIR=/home/nao/naoqi/ctc-linux64-atom-2.5.10.7/icu/share/cmake/icu
SYSTEMD_DIR=/home/nao/naoqi/ctc-linux64-atom-2.5.10.7/systemd/share/cmake/systemd

And now I got another error:

qibuild configure --release -c android-armCurrent build worktree: /home/nao/worktree
Using toolchain: android-arm
* (1/1) Configuring qimessaging-jni
-- Adjusting Android API level 'android-17' to 'android-14'
-- Using qibuild 3.17
-- Library: qimessagingjni
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find RT (missing: RT_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  /home/nao/.local/share/cmake/qibuild/find.cmake:373 (find_package_handle_standard_args)
  /home/nao/.local/share/cmake/qibuild/find.cmake:269 (_qi_call_fphsa)
  /home/nao/.local/share/cmake/qibuild/modules/rt-config.cmake:8 (export_lib)
  /home/nao/.local/share/cmake/qibuild/internal/uselib.cmake:80 (find_package)
  /home/nao/.local/share/cmake/qibuild/internal/uselib.cmake:94 (_qi_use_lib_get_deps)
  /home/nao/.local/share/cmake/qibuild/internal/uselib.cmake:94 (_qi_use_lib_get_deps)
  /home/nao/.local/share/cmake/qibuild/internal/uselib.cmake:197 (_qi_use_lib_get_deps)
  /home/nao/.local/share/cmake/qibuild/stage.cmake:247 (_qi_use_lib_internal)
  /home/nao/.local/share/cmake/qibuild/target.cmake:277 (qi_use_lib)
  CMakeLists.txt:59 (qi_create_lib)

-- Configuring incomplete, errors occurred!
See also "/home/nao/worktree/libqi-java/jni/build-android-arm/CMakeFiles/CMakeOutput.log".
victorpaleologue commented 2 years ago

Hello,

Instead of patching your /etc/environment, you should be trying to build the libqi-java that is found under ~/work/aldebaran. Normally, qibuild will find the other projects of the worktree, and set these automatically.

Then, it is possible that the Android NDK you defined to use with set(ANDROID_TOOLCHAIN_NAME "arm-linux-androideabi-4.4.3") does not have the right libraries, such as RT (but I admit I find that weird). Let us try with the right NDK, first.

According to the CMake code in the qibuild toolchain package for the Android NDK, it is designed to work with the NDK version r10c.