5

我需要在 android 4.1 设备上安装 iw 无线包。但我不知道要安装的软件包的要求版本和方式!

是否需要 linux 平台来执行此操作,或者在 adb shell 上为 android 生根设备构建和安装就足够了。

我看到了这个链接,但是当我从 adb 终端执行此操作时,我看到 git 和一些未找到的 shell ???怎么做 ?

好像没人知道??

4

1 回答 1

1

在构建 iw 版本 3.11(已经有一个 Android.mk 文件)时,由于缺少/错误的标头和库,我遇到了一些问题。由于它有一个 Android.mk 文件,因此可以使用 NDK。

在下文中,我将假设以下内容:

  • 之前已经构建了设备映像(内核头文件和 libnl-2 静态库至少应该可用)。我为 i9300 构建了 CyanogenMod 10(内核 3.0.something),更新下面的路径以反映这一点。
  • NDK 安装到~/android/system/ndk.
  • NDK 已安装适当的平台和工具链。

提取iw-3.11.tar.xz和更改我的目录后的准备工作:

ln -s . jni
ln -nsv ~/android/system/external ./

下一个问题是 netlink 库:

In file included from external/libnl-headers/netlink/genl/genl.h:15:0,
                 from /tmp/and/iw/jni/iw.c:17:
external/libnl-headers/netlink/netlink.h:27:29: fatal error: linux/genetlink.h: No such file or directory.

简单地创建一个链接到android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux破坏其他标题的链接会产生错误,例如:

Compile thumb  : iw <= iw.c
In file included from /home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/net/if.h:28:0,
                 from /tmp/and/iw/jni/iw.c:10:
/tmp/and/iw/jni/linux/if.h:178:19: error: field 'ifru_addr' has incomplete type
/tmp/and/iw/jni/linux/if.h:179:19: error: field 'ifru_dstaddr' has incomplete type
/tmp/and/iw/jni/linux/if.h:180:19: error: field 'ifru_broadaddr' has incomplete type
/tmp/and/iw/jni/linux/if.h:181:19: error: field 'ifru_netmask' has incomplete type
/tmp/and/iw/jni/linux/if.h:182:20: error: field 'ifru_hwaddr' has incomplete type
In file included from external/libnl-headers/netlink/netlink.h:20:0,
                 from external/libnl-headers/netlink/genl/genl.h:15,
                 from /tmp/and/iw/jni/iw.c:17:
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:74:44: warning: 'struct msghdr' declared inside parameter list [enabled by default]
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:74:44: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:75:38: warning: 'struct msghdr' declared inside parameter list [enabled by default]
In file included from external/libnl-headers/netlink/netlink.h:25:0,
                 from external/libnl-headers/netlink/genl/genl.h:15,
                 from /tmp/and/iw/jni/iw.c:17:
/tmp/and/iw/jni/linux/netlink.h:33:2: error: unknown type name 'sa_family_t'
In file included from external/libnl-headers/netlink/genl/genl.h:15:0,
                 from /tmp/and/iw/jni/iw.c:17:
external/libnl-headers/netlink/netlink.h:51:16: warning: 'struct msghdr' declared inside parameter list [enabled by default]
external/libnl-headers/netlink/netlink.h:54:19: warning: 'struct iovec' declared inside parameter list [enabled by default]
make: *** [/tmp/and/iw/obj/local/armeabi/objs/iw/iw.o] Error 1

一种解决方法是创建linux目录并将符号链接~/android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux/genetlink.h放入其中:

mkdir -p linux
ln -svn ~/android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux/genetlink.h linux/

最后打补丁Android.mk以完成对 netlink 库的链接:

sed "/LOCAL_LDFLAGS/s#\$# -L$HOME/android/system/out/target/product/i9300/obj/STATIC_LIBRARIES/libnl_2_intermediates -lnl_2#" -i Android.mk

现在可以开始构建:

NDK_PROJECT_PATH=$PWD ~/android/system/ndk/ndk-build TARGET_PLATFORM=android-14

它不会完成,因为找不到 netlink/genl/genl.h,但iw 二进制文件在 libs/armeabi 中可用!

于 2013-10-23T13:45:46.893 回答