1

How can I build an executable with Android NDK (include $(BUILD_EXECUTABLE)) but with file extension.

Here is my Android.mk

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := ls
LOCAL_SRC_FILES := ls.c

include $(BUILD_EXECUTABLE)

It works as expected, but file is without extension. If library doesn't have .so extension it doesn't get packed into the apk.

Onik
  • 19,396
  • 14
  • 68
  • 91
pedja
  • 3,285
  • 5
  • 36
  • 48
  • 1
    Found the following posts that might help: 1) - [Hosting an executable within Android application](http://stackoverflow.com/questions/5583487/hosting-an-executable-within-android-application); 2) - [Package Android apk with additional executables](http://stackoverflow.com/questions/6998419/package-android-apk-with-additional-executables); 3) - [How to package native commandline application in apk?](http://stackoverflow.com/questions/17383552/how-to-package-native-commandline-application-in-apk). – Onik Jan 23 '16 at 20:57

1 Answers1

0

I did his:

#!/usr/bin/env bash

ndk-build
cd ../libs
for f in $(ls .);
do
    mv $f/ls $f/libls.so
done

This script should be put in jni folder, and instead of calling just ndk-build i call this script.
Its not dynamic, name of the executable is hardcoded, but is does the job in my case.

pedja
  • 3,285
  • 5
  • 36
  • 48