Android: Executing a program on adb shell

杀马特。学长 韩版系。学妹 提交于 2019-12-20 04:05:30

问题


I have created an executable using "include $(BUILD_EXECUTABLE)" command in Android.mk . My requirement is to execute the above generated executable over the abd shell.

I tried:

Below is my C-Code which is compiled using ndk-build command:

#include <stdio.h>
int main()
{
    printf("\n\nHello World\n\n");
    return 0;
}

Following is my Android.mk file contents:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := HelloExecutable
LOCAL_SRC_FILES := hello.c
include $(BUILD_EXECUTABLE)

When i execute the command ndk-build the following file is generated:

projectRoot->libs->HelloExecutable

My job is to execute the above generated file on the adb shell. So i first pushed the file onto the sdcard using the following command:

adb push ~/projectRoot->libs->HelloExecutable /sdcard/

Now i switch to adb shell using: $adb shell command(here i'm using an emulator).

Then i change the permissions as: chmod 777 /sdcard/HelloExecutable

Once the above command is executed, i get the executing permissions for my HelloExecutable file.

Then change the current working directory to sdcard. i.e. cd /sdcard/

Now when i try to execute the above file i get the following error:

# ./HelloExecutable
./HelloExecutable: permission denied

To perform the above i'm using an emulator. So can someone please tell the reason for the above error??

I kindly request the viewers to address the above problem. Waiting for your answers. Thanks in advance.


回答1:


Check if your SD card is mounted with noexec option. Try copying your file to another partition like /data and execute it from there.



来源:https://stackoverflow.com/questions/15162276/android-executing-a-program-on-adb-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!