在 Android 上安装预构建的二进制文件:“未找到"

在 Android 上安装预构建的二进制文件:“未找到

问题描述:

我正在尝试在自定义 Android 映像中安装预构建的二进制文件.为此,我已将其复制到 prebuilt/android-arm/ 中的一个新目录中,其中包含一个与此类似的 Android.mk 文件:

I'm trying to install a prebuilt binary in a custom Android image. For that I have copied it to a new directory in prebuilt/android-arm/ with an Android.mk file similar to this one:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := binary_name
LOCAL_MODULE := binary_name
LOCAL_MODULE_CLASS := EXECUTABLES
include $(BUILD_PREBUILT)

因此,如果我运行 make system_image binary_name,二进制文件将复制到系统映像中的 /bin/.如果我运行模拟器,我可以在 /system/bin 中看到二进制文件.权限与其他可执行文件 (-rwxr-xr-x) 相同,并且根据 file,这是一个 ARM 二进制文件(ELF 32 位LSB 可执行文件,ARM,版本 1 (SYSV),动态链接(使用共享库),剥离).

So if I run make system_image binary_name, the binary file is copied to /bin/ in system image. And if I run the emulator I can see the binary file in /system/bin. The permissions are the same as the other executables (-rwxr-xr-x) and, according to file, this is an ARM binary (ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped).

但是当我在模拟器上运行它时,它说:

But when I run it on the emulator, it says:

# binary_name
binary_name: not found

我已经跟踪了它,这是我能看到的:

I have straced it and this is what I can see:

# strace binary_name
execve("/system/bin/binary_name", ["binary_name"], [/* 9 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec", 12strace: exec)            = 12
write(2, ": ", 2: )                       = 2
write(2, "No such file or directory", 25No such file or directory) = 25
write(2, "\n", 1
)                       = 1
io_submit(1, -1344063348, {...} <unfinished ... exit status 1>

但是文件在那里,strace 能够找到它.

But the file is there, and strace is able to find it.

知道会发生什么吗?

更新:正如 Kristof 所说,这可能是动态链接的问题,但我没有 Android ARM 的 ldd...

UPDATE: As Kristof says, this is probably a problem of dynamic linking, but I don't have ldd for Android ARM...

可能找不到某些所需的动态库.

Perhaps some of the required dynamic libraries can't be found.

试试'ldd binary_name'

Try 'ldd binary_name'

如果可以找到所有库,输出应该看起来像这样.应该清楚地标记缺失的库.

The output should look a little like this if all libraries can be found. Missing libraries should be clearly marked.

linux-gate.so.1 =>  (0xb7fbf000)
libcap.so.2 => /lib/libcap.so.2 (0xb7fa7000)
libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7fa3000)
libncursesw.so.5 => /lib/libncursesw.so.5 (0xb7f64000)
libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7f3e000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7dde000)
libattr.so.1 => /lib/libattr.so.1 (0xb7dd9000)
/lib/ld-linux.so.2 (0xb7fc0000)