openthread / ot-commissioner

OpenThread Commissioner, a Thread commissioner for joining new Thread devices and managing Thread networks.
https://openthread.io/
BSD 3-Clause "New" or "Revised" License
49 stars 36 forks source link

ANDROID_NDK_HOME location #215

Closed OlivierGre closed 3 years ago

OlivierGre commented 3 years ago

In the build guidelines for the Android App there is: ANDROID_ABI=arm64-v8a ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk-bundle ./build-commissioner-libs.sh

I'm confused about what I should put instead of $HOME/Library/Android/sdk/ndk-bundle.

I have installed "NDK (Side by side)" as indicated on https://developer.android.com/studio/projects/install-ndk In my SDK directory, I now have a ndk directory containing another directory called "22.1.7171670". I'm wondering where should be the ndk-bundle directory.

Thanks

OlivierGre commented 3 years ago

I'm now using ANDROID_ABI=arm64-v8a ANDROID_NDK_HOME=/local/android/Sdk/ndk/22.1.7171670 ./build-commissioner-libs.sh

I don't have anymore error but it never ends so I guess that something is failing. Is there a way to see what's going on?

By the way, I had to use a root account otherwise I had an error message.

wgtdkp commented 3 years ago

ANDROID_NDK_HOME=/local/android/Sdk/ndk/22.1.7171670

This is correct.

  1. Can you paste the output of below command?
    ANDROID_ABI=arm64-v8a ANDROID_NDK_HOME=/local/android/Sdk/ndk/22.1.7171670 ./build-commissioner-libs.sh
  2. Can you paste the error without running as root?
OlivierGre commented 3 years ago
  1. There is absolutely no output

  2. Here is the output when not running as root:

ANDROID_ABI=arm64-v8a ANDROID_NDK_HOME=/local/android/Sdk/ndk/22.1.7171670 ./build-commissioner-libs.sh
CMake Error at CMakeLists.txt:30 (project):
  Running

   '/usr/sbin/ninja' '--version'

  failed with:

   die: error: must run as root

-- Configuring incomplete, errors occurred!
See also "/local/MMY_GIT/android/ot-commissioner/android/.build-arm64-v8a/CMakeFiles/CMakeOutput.log".

Here is the content of CMakeOutput.log:

The target system is: Android - 1 - aarch64
The host system is: Linux - 4.4.0-210-generic - x86_64
wgtdkp commented 3 years ago

I will expect ninja being installed in /usr/bin but not /usr/sbin. Did you install ninja with ./script/bootstrap.sh ?

OlivierGre commented 3 years ago

If I remember correcly, I have installed it with "sudo apt-get install ninja". Is this location (in /usr/sbin) an issue?

BTW, I haven't used the script "./script/bootstrap.sh". Did I miss something?

wgtdkp commented 3 years ago

I don't think a non-root user has the permission to run binaries in /usr/sbin, that's why you need to run ./build-commissioner-libs.sh as root.

You should run ${OT_COMMISSIONER_ROOT_DIR}/script/bootstrap.sh before trying anything else, I updated ./build-commissioner-libs.sh to always run script/bootstrap.sh: ./build-commissioner-libs.sh: https://github.com/openthread/ot-commissioner/pull/216.

OlivierGre commented 3 years ago

I have uninstalled ninja with: apt remove ninja-build

Then I have called "./script/bootstrap.sh" and it has installed ninja. I now have it here:

which ninja
/usr/bin/ninja

This is fixing the issue. I then get another issue :

CMake Error at /usr/local/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find SWIG: Found unsuitable version "3.0.8", but required is at
  least "4.0" (found /usr/bin/swig, )

I need to reinstall the packages properly.

You should run ${OT_COMMISSIONER_ROOT_DIR}/script/bootstrap.sh before trying anything else,

You may want to update https://github.com/openthread/ot-commissioner/blob/main/android/BUILDING.md

I updated ./build-commissioner-libs.sh to always run script/bootstrap.sh: ./build-commissioner-libs.sh: #216.

"bootstrap.sh" requires root privilege (in order to install some packages). That might be a problem if you call it every times from "build-commissioner-libs.sh". People like me have to contact the "IT" to get someone call the script with root privilege. That would be nice if only the installation of the dependencies require root privilege. For the rest, we could call "build-commissioner-libs.sh" without root privilege.

wgtdkp commented 3 years ago

"bootstrap.sh" requires root privilege (in order to install some packages). That might be a problem if you call it every times from "build-commissioner-libs.sh". People like me have to contact the "IT" to get someone call the script with root privilege. That would be nice if only the installation of the dependencies require root privilege. For the rest, we could call "build-commissioner-libs.sh" without root privilege.

Makes sense to me, updated.

wgtdkp commented 3 years ago

CMake Error at /usr/local/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find SWIG: Found unsuitable version "3.0.8", but required is at least "4.0" (found /usr/bin/swig, )

I need to reinstall the packages properly.

What's your linux distribution and version? And how did you fix it?

OlivierGre commented 3 years ago

Makes sense to me, updated.

Thanks

What's your linux distribution and version? And how did you fix it?

I'm on an "old" Ubuntu 16.04. I haven't fixed it yet. I had the same problem with cmake and I had to download the source rebuild it and install it. I will probably have to do the same here.

OlivierGre commented 3 years ago

And how did you fix it?

I have followed the instructions here: https://www.dev2qa.com/how-to-install-swig-on-macos-linux-and-windows/

I now have the version 4.0.2.

I'm reaching another error:

CMake Error at third_party/CMakeLists.txt:42 (add_subdirectory):
  The source directory

    /local/MMY_GIT/android/ot-commissioner/third_party/fmtlib/repo

  does not contain a CMakeLists.txt file.

NB: There are several errors like this (+ some warnings).

I attach the full log. log.txt

OlivierGre commented 3 years ago

I suspect that it is because I have jumped straight into the compilation of the Android App. I might have to build some third party libraries first. Can you please point me the procedure? Thanks

wgtdkp commented 3 years ago

The script/bootstrap.sh will checkout submodules for you at the end of the file. I will suggest you edit the script to comment out the swig from sudo apt-get install... list and rerun ./build-commissioner-libs.sh.

If the similar error still appears, run below command and then try again ./build-commissioner-libs.sh:

git submodule foreach --recursive git checkout master
OlivierGre commented 3 years ago

Sorry for the late answer, I was out of the office.

The problem was due to the fact that I had used git clone https://github.com/openthread/ot-commissioner.git instead of git clone https://github.com/openthread/ot-commissioner.git --recursive

build-commissioner-libs.sh is now successful.

Concerning bootstrap script, would it be possible to split it in two scripts? One installing dependencies (and thus requiring root privilege) and one for the rest (like the update of git sub modules).

A side comment: At the end of bootstrap script, there is this command which is failing on my side:

git submodule update --init --recursive --depth=1 --progress
usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
   or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
   or: git submodule [--quiet] init [--] [<path>...]
   or: git submodule [--quiet] deinit [-f|--force] [--] <path>...
   or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--reference <repository>] [--recursive] [--] [<path>...]
   or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
   or: git submodule [--quiet] foreach [--recursive] <command>
   or: git submodule [--quiet] sync [--recursive] [--] [<path>...]

This is not a blocking issue right now because I have juste cloned the repository so all the submodules are uptodate.

wgtdkp commented 3 years ago

At the end of bootstrap script, there is this command which is failing on my side:

This is probably because your git version is too old. Try updating the git package.

OlivierGre commented 3 years ago

I have the most recent version of GIT (v2.7.4) for my environment (I'm on Ubuntu 16.04 which is old). I will soon move to a new PC with a new Ubuntu version.