0

如何使用arm-linux-androideabi编译器为 android 编译和构建iotivity-lite ( https://github.com/iotivity/iotivity-constrained )?我对Makefile更改和设置感兴趣。

4

1 回答 1

1

为 Android 构建 iotivity-lite 的说明可通过 Makefile 中的自述文件格式获得。

[iotivity-lite]/port/android/Makefile

链接到 Andorid Makefile

从那个make文件:

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

下载 NDK 后,确保运行make_standalone_toolchain.py脚本。要为 arm 构建调试版本,我最终运行以下命令。

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

构建指令仅限于构建必须使用 adb shell 运行的 C 代码。

在我写这篇文章的时候,有一个单独的分支正在使用 JNI 将 IoTivity-lite 暴露给 Java。这是 swig 分支。

有一个自述文件,其中包含构建 Java API 的说明以及一些示例程序。

swig 分支的 README 说明

swig 分支仍在积极开发中,但应该足够稳定以满足您的需求。

编辑:
自从提出这个问题以来,swig 分支已与 iotivity-lite 的主分支合并。另请注意,由于询问了此问题,因此存储库名称已从更改iotivity-constrainediotivity-lite. 为 Android 构建所需的一切都应该在[iotivity-lite]/port/android/README.md文件中。

于 2019-02-25T20:56:53.157 回答