An Android application which allows to execute native program built by
Please read this article for more details: http://web.guohuiwang.com/technical-notes/nativelauncher
- Do not require ROOT permission. Enabling native program execution on non-rooted devices.
- Allows to run native code without USB cable and ADB. This is very important for some special purpose, for example, if we want to measure power consumption of the devices when running the native code, we don't want to connect USB cable which will provide power to the device.
- Help debug native code before porting it using JNI code in an Android app.
- Support loading native program from sdcard.
- Support command line arguments.
- Allow the user to set up
- Support subfolders. Input files and configurations loaded by the native program can be put in subfolders, in the native program, use relative path to access them.
- Support output files. Output files can be retrieved from the working directory.
- Install is simple. Download the apk file under
android_apk, and install it on your Android device. Then you are good to go.
- Copy your native program (compiled by
ndk-build) in a folder on your sdcard, e.g.
- Copy all dependent shared libraries (.so) to that folder.
- Copy input files to the same folder.
- Press the button "Load native program".
- Set command line arguments if there is any.
- Press button "Run" to execute the program.
- Check results under your folder, such as
- Q: Where is the working directory?
- A: The working directory is the directory the executable located.
- Q: How to set
LD_LIBRARY_PATH? What is the library loading order?
- A: In the textedit field, type your custom library path. Please notice that, your working directory will be added to
LD_LIBRARY_PATHautomatically. For example, if you type "
mylib" in the field, the
LD_LIBRARY_PATHwill be set as
- Q: How to use subfolder?
- A: Subfolder can be accessed via relative path. For example, if we have a folder named "
image" in working directory containing an input image "
lena.png", in your code, you can access it via
image/lena.png. Your output files will also be under the working directory.
- Q: I was not able to load the binary after I clicked "Load Native Program" button?
- A: On some devices (especially some factory testing devcies), there is no default file explorer. Please install one from the Google Play Store. Basically, any file explorer can do the job. The "ES file explorer" is a good one to start, if you have no preference.
Two examples are provided to demonstrate the usage of native program launcher. Pre-compiled binaries are provided under
bin folder. But you can also compile them using ndk-bulid.
- Compile the examples with Android NDK:
- Have ndk installed and ndk-build is in the system path.
- in shell, run
./build_examples.sh. Then you have the binareis in bin folder
$ cd examples $ ./build_examples.sh
- example1 shows basic usage, and command line arguments. You can set up command line arguments, and they will be displayed one by one.
- example2 shows the case where we have executable file along with shared library.
Copyright 2015 Guohui Wang Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.