首页 > 解决方案 > Android 5.1.1 - 构建运行方式二进制

问题描述

我正在尝试从 android lollipop 源构建一个 run-as 二进制文件。我在这里下载了 run-as 包:https ://android.googlesource.com/platform/system/core/+archive/android-cts-5.1_r28/run-as.tar.gz

好吧,这里是 Android.mk 代码:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := run-as.c package.c
LOCAL_SHARED_LIBRARIES := libselinux
LOCAL_MODULE := run-as
LOCAL_CFLAGS := -Werror
include $(BUILD_EXECUTABLE)

当我尝试构建时,我收到此错误:

Android NDK: Module run-as depends on undefined modules: selinux
*** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies)

所以我将此行添加到我的 android.mk 文件中

APP_ALLOW_MISSING_DEPS=true

然后,我从这里(android_filesystem_config.h) 和从这里(android.h) 下载头文件,以包含 run-as.c 所需的正确头文件

但是当我再次尝试构建时,我遇到了这个错误:

./run-as.c:158: error: undefined reference to 'selinux_android_setcontext'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

我想我在构建过程中错过了一些东西......我们将不胜感激。

谢谢

标签: androidmakefilecmakeandroid-ndkndk-build

解决方案


推荐阅读