Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A full explanation, as your Android.mk does not make much sense to me: sorry if you already know some of that.</p> <p>Static libraries should be pure C/C++, and wrapped using the Android NDK in order to be usable from Java.</p> <p>For example, assuming your static library is built from a simple .c and .h files:</p> <p><em>highfive.h:</em></p> <pre><code>int giveMeFive(); </code></pre> <p><em>highfive.c:</em></p> <pre><code>#include "highfive.h" int giveMeFive() { return 5; } </code></pre> <p>This can be compiled as a static library using the Android NDK compiler, which apparently you already know how to do: this will give us a <code>highfive.a</code> library.</p> <p>In this form, this library is unusable from Java, but it can be wrapped using the Android NDK. See the Android NDK documentation for naming conventions etc...</p> <p><em>highfiveWrapper.c:</em></p> <pre><code>#include "highfive.h" jint Java_your_package_name_HighFive_giveMeFive(JNIEnv *env, jobject o) { return (jint) giveMeFive(); } </code></pre> <p>and its corresponding Java file:</p> <pre><code>package your.package.name; class HighFive { static { System.loadLibrary("highfive"); } public native int giveMeFive(); } </code></pre> <p>Now, how do we compile all this to get it to work:</p> <p><em>Android.mk:</em></p> <pre><code>include $(CLEAR_VARS) LOCAL_MODULE := libhighfive-prebuilt LOCAL_SRC_FILES := path/to/highfive.a LOCAL_EXPORT_C_INCLUDES := path/to/highfive.h/folder include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := highfive LOCAL_SRC_FILES := path/to/highfiveWrapper.c LOCAL_STATIC_LIBRARIES := libhighfive-prebuilt include $(BUILD_SHARED_LIBRARY) </code></pre> <p>And there you should be able to use your native library as you wished to!</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload