0

How to compile and build iotivity-lite (https://github.com/iotivity/iotivity-constrained) for android using arm-linux-androideabi compiler? I'm interested in the Makefile changes and settings.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Michael Kanzieper
  • 709
  • 1
  • 10
  • 20

1 Answers1

1

The instructions for building iotivity-lite for Android are available by in a readme format inside the Makefile.

go to [iotivity-lite]/port/android/Makefile

Link to the Andorid Makefile

from that make file:

Port for native Android compilation (without Java).
Tested NDK versions:
API   Android version
  19   4.4
  21   5.0
  23   6.0
  24   7.0

 API version 24 is closest to regular Linux so far.
 With API 24 the Android port is almost identical to the Linux port
 except for the removal of the unsupported pthread_cancel and that
 the IP adapter assures that interfaces have multicast and broadcast
 enabled to avoid 3G/4G/5G interfaces.

 It is expected that higher versions then API 24 should work without any
 further modifications.

 Testing compilations on non-rooted Android phones:
 - Enable USB debugging on your phone.
 - Install ADB or Android Studio
 - adb start-server
   Your phone should query now if you trust the computer. Hit OK.
 - adb push simpleclient /data/local/tmp/
   Most likely your phone gives you in /data/local some more permissions
   Non-rooted devices are a bit restrictive what you can do in the file system.
 - adb shell
 - cd /data/local/tmp
 - chmod 755 simpleclient
   It was observed that the file has read-write permissions only after the upload
   on Android 7.
 - In a different terminal window start simpleserver on your developer box.
 - ./simpleclient
 - Kill client with Ctrl-C or Ctrl-\
 - exit
 - *** DISABLE USB debugging!!! *** (security issue if left on)

 Note: On regular Android phones the server versions will not be found
       (ie. simpleserver will not be discovered). But the clients
       should work.

 Download NDK: https://developer.android.com/ndk/downloads/index.html
 Unzip downloaded package.
 Choose architecture and API level.
 cd <NDK>/build/tools
 ./make_standalone_toolchain.py --arch <architecture> --api <level> --install-dir <path>
 For example: ./make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23
 This makefile uses then the NDK in <install-dir>.
 For further setup see: https://developer.android.com/ndk/guides/standalone_toolchain.html

 Either set ANDROID_API and ANDROID_BASE in this makefile
 or invoke like this: make NDK_HOME=/opt/android-ndk ANDROID_API=24

After downloading the NDK make sure you run the make_standalone_toolchain.py script. To build debug version for arm I end up running the following command.

make NDK_HOME=~/Android/android-arm-23/ ANDROID_API=23 DYNAMIC=1 TCP=1 SECURE=1 DEBUG=1

The build instructions are limited to building the C code that must be run using adb shell.

At the time I am writing this, There is a separate branch that is working to expose IoTivity-lite to Java using JNI. This is the swig branch.

There is a readme that contains the instructions to build the Java APIs as well as some sample programs.

README instructions for swig branch

The swig branch is still under active development but should be stable enough to meet your needs.

edit:
Since this question was asked the swig branch has been merged with the master branch of iotivity-lite. Also note since this question was asked the repository name was changed from iotivity-constrained to iotivity-lite. Everything needed to build for Android should be in the [iotivity-lite]/port/android/README.md file.

gnash117
  • 1,025
  • 1
  • 13
  • 24