简体   繁体   中英

Android: Executing a program on adb shell

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. ie 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM