First, you have to push it into a directory, such as /data/local/tmp
. Then, you have to set permission for that using chmod 755 executable
. After that, you can run it as ./executable
.
Complete steps are as follows:
adb push executable /data/local/tmp
adb shell
cd /data/local/tmp
chmod 755 executable
./executable
Alternatively, if you want to run it from your asset folder, you have to copy the file to your data folder /data/data/packagename/
. Then using File
class, set the setExecutable
flag to true
for the file and run it by the Process class or third party packages like Root Tools .
UPDATE
if you are targeting sdk 29 or higher you CANNOT use the binary from your asset folder ! you have to copy your binary to jnilib folder then run it from native library directory ! context.getApplicationInfo().nativeLibraryDir
chmod +x pgm
and then./pgm
also?noexec
flag. You either need to move it into the phone's internal storage, or run it via a shell (e.g.sh /path/to/myexecutable
).