0

I have compiled a native application, a terminal only application basically, with the android NDK, my main problem right is that I can't change the permissions on my executable ( a dynamically linked one ) like so chmod +x executable to test and use the application.

I need to root my device just to do that ?

I tried with both adb shell and a random terminal application directly from my phone.

user2485710
  • 8,623
  • 9
  • 48
  • 92

3 Answers3

2

These guys say root is needed: How to compile C into an executable binary file and run it in Android from Android Shell?

From my understanding, the regular sdcard is mounted with no execution permission, so you need to write to something like /data/local/, which indeed requires root access.

Community
  • 1
  • 1
Damian
  • 161
  • 1
  • 7
2

No, you don't need to root a device to use executable binaries. You cannot put it on /sdcard but on most devices there is a directory /data/tmp or /data/local/tmp where you can push files with adb and execute with adb shell.

The robust option is to package an executable in an APK and get it on device by installing the APK, see Is it possible to run a native arm binary on a non-rooted android phone? or How to package native commandline application in apk?.

Note that you cannot change the LD_LIBRARY_PATH, so be careful if your executable depends on some shared libs that are not part of /system/lib.

Community
  • 1
  • 1
Alex Cohn
  • 52,705
  • 8
  • 94
  • 269
1

If you don't package your native code as an Android app, you'll need to run it from shell.

Starting with Android KitKat/Lollipop, executables can only be run from restricted locations. eg an executable installed in /data/data//... will not be allowed to run in any ways, be it with or without root.

Before KitKat, one can copy the executable to its own data directory, make it executable and run it. Not anymore in more recent version of KitKat.

So you will definitively need root to run linux exe on recent versions of Android.

3c71
  • 3,574
  • 21
  • 42