Giter VIP home page Giter VIP logo

androidnativelauncher's Introduction

Android NDK Native Program Launcher

An Android application which allows to execute native program built by ndk-buld.

Please read this article for more details: http://web.guohuiwang.com/technical-notes/nativelauncher

Screenshot

NativeLauncher screenshot

Benifits

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

Features

  • Support loading native program from sdcard.
  • Support command line arguments.
  • Allow the user to set up LD_LIBRARY_PATH.
  • 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

  • Install is simple. Download the apk file under android_apk, and install it on your Android device. Then you are good to go.

Instructions

  1. Copy your native program (compiled by ndk-build) in a folder on your sdcard, e.g. /sdcard/test/.
  2. Copy all dependent shared libraries (.so) to that folder.
  3. Copy input files to the same folder.
  4. Press the button "Load native program".
  5. Set command line arguments if there is any.
  6. Press button "Run" to execute the program.
  7. Check results under your folder, such as /sdcard/test/.

FAQ

  1. Q: Where is the working directory?
  • A: The working directory is the directory the executable located.
  1. 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_PATH automatically. For example, if you type "mylib" in the field, the LD_LIBRARY_PATH will be set as LD_LIBRARY_PATH=mypath:working_directory:$LD_LIBRARY_PATH.
  1. 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.
  1. 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.

Examples

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.

  1. Compile the examples with Android NDK:
  2. Have ndk installed and ndk-build is in the system path.
  3. in shell, run ./build_examples.sh. Then you have the binareis in bin folder
$ cd examples
$ ./build_examples.sh
  1. example1 shows basic usage, and command line arguments. You can set up command line arguments, and they will be displayed one by one.
  2. example2 shows the case where we have executable file along with shared library.

License

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.

androidnativelauncher's People

Contributors

robertwgh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

androidnativelauncher's Issues

Apk

Where can I get on GitHub APK downloads?

Can you Give the Original Application Source Code

Hello sir,
Nice to meet You.

I'm Mohamed Learning JNI From Scratch if You are Give the Original Source Code. This code is not contained some android specification app folder if you are deleted it or mistakenly not uploaded it will helpful for my research sir

unable to open executable

Hi, thanks for sharing the tutorial and APK. I met a problem that I am unable to open executable (cannot select). The phone is Samsung Galaxy S6. Any help would be appreciated.

Screenshot_20191222-110248

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.