Okay before you flag this as a duplicate I have tried the following
No implementation found for native
No implementation found for native Stitch
No Implementation found for native in ndk
No implementation found for native Lcom/jp/algi/
Android NDK C++ JNI (no implementation found for native...)
Android NDK: No implementation found for native xxxxxx
here is my MainActivity.java
public class MainActivity extends Activity {
static {
System.loadLibrary("physfs");
System.loadLibrary("jpeg");
System.loadLibrary("tiff");
System.loadLibrary("mng");
System.loadLibrary("png");
System.loadLibrary("jasper");
System.loadLibrary("lcms");
System.loadLibrary("devil");
System.loadLibrary("mylib");
}
public static native void convert();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
convert();
}
}
the c file
#include "com_myproject_MainActivity.h"
#include <string.h>
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
JNIEXPORT void JNICALL Java_com_myproject_MainActivity_convert
(JNIEnv *, jclass){
.....
}
the javah generated header snippet
#define com_myproject_MainActivity_DEFAULT_KEYS_SHORTCUT 2L
#undef com_myproject_MainActivity_DEFAULT_KEYS_SEARCH_LOCAL
#define com_myproject_MainActivity_DEFAULT_KEYS_SEARCH_LOCAL 3L
#undef com_myproject_MainActivity_DEFAULT_KEYS_SEARCH_GLOBAL
#define com_myproject_MainActivity_DEFAULT_KEYS_SEARCH_GLOBAL 4L
/*
* Class: com_myproject_MainActivity
* Method: convert
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_myproject_MainActivity_convert
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif
the portion of the android.mk file that sources the C file
#mylib
include $(CLEAR_VARS)
LOCAL_MODULE := libmylib
LOCAL_CFLAGS := -g -Dlinux -DFT2_BUILD_LIBRARY=1 -DPHYSFS_NO_CDROM_SUPPORT=1 -DAL_ALEXT_PROTOTYPES=1 -DHAVE_GCC_DESTRUCTOR=1 -DOPT_GENERIC -DREAL_IS_FLOAT
LOCAL_CPPFLAGS := ${LOCAL_CFLAGS}
LOCAL_C_INCLUDES := \
${DEVIL_SRC_PATH}include \
${DEVIL_SRC_PATH}src-IL/include \
${JASPER_SRC_PATH}src/libjasper/include \
${PNG_SRC_PATH} \
${MNG_SRC_PATH} \
${JPEG_SRC_PATH} \
${LCMS_SRC_PATH}include/ \
${TIFF_SRC_PATH}libtiff/ \
LOCAL_SRC_FILES := com_myproject_MainActivity.c
include $(BUILD_SHARED_LIBRARY)
I have tried the C file as .cpp and used extern "C" in all possible ways no result. I have also deleted the bin,out,libs and obj folders several times and freshly built. The code compiles and .so files are made.
But I can't run it this is the log
> 08-02 01:59:07.268: E/Trace(1569): error opening trace file: No such
> file or directory (2) 08-02 01:59:07.268: D/dalvikvm(1569): Trying to
> load lib /data/data/com.myproject/lib/libphysfs.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libphysfs.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libphysfs.so 0xb63c3518, skipping init
> 08-02 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/libjpeg.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libjpeg.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libjpeg.so 0xb63c3518, skipping init
> 08-02 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/libtiff.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libtiff.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libtiff.so 0xb63c3518, skipping init
> 08-02 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/libmng.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libmng.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libmng.so 0xb63c3518, skipping init 08-02
> 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/libpng.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libpng.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libpng.so 0xb63c3518, skipping init 08-02
> 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/libjasper.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libjasper.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libjasper.so 0xb63c3518, skipping init
> 08-02 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/liblcms.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/liblcms.so 0xb63c3518 08-02 01:59:07.268:
> D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/liblcms.so 0xb63c3518, skipping init
> 08-02 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/libdevil.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libdevil.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libdevil.so 0xb63c3518, skipping init
> 08-02 01:59:07.268: D/dalvikvm(1569): Trying to load lib
> /data/data/com.myproject/lib/libmylib.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): Added shared lib
> /data/data/com.myproject/lib/libmylib.so 0xb63c3518 08-02
> 01:59:07.268: D/dalvikvm(1569): No JNI_OnLoad found in
> /data/data/com.myproject/lib/libmylib.so 0xb63c3518, skipping init
> 08-02 01:59:07.288: W/dalvikvm(1569): No implementation found for
> native Lcom/myproject/MainActivity;.convert:()V 08-02 01:59:07.288:
> D/AndroidRuntime(1569): Shutting down VM 08-02 01:59:07.288:
> W/dalvikvm(1569): threadid=1: thread exiting with uncaught exception
> (group=0xb5e5e288) 08-02 01:59:07.288: E/AndroidRuntime(1569): FATAL
> EXCEPTION: main 08-02 01:59:07.288: E/AndroidRuntime(1569):
> java.lang.UnsatisfiedLinkError: Native method not found:
> com.myproject.MainActivity.convert:()V 08-02 01:59:07.288:
> E/AndroidRuntime(1569): at com.myproject.MainActivity.convert(Native
> Method) 08-02 01:59:07.288: E/AndroidRuntime(1569): at
> com.myproject.MainActivity.onCreate(MainActivity.java:30) 08-02
> 01:59:07.288: E/AndroidRuntime(1569): at
> android.app.Activity.performCreate(Activity.java:5008) 08-02
> 01:59:07.288: E/AndroidRuntime(1569): at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
> 08-02 01:59:07.288: E/AndroidRuntime(1569): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
> 08-02 01:59:07.288: E/AndroidRuntime(1569): at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
> 08-02 01:59:07.288: E/AndroidRuntime(1569): at
> android.app.ActivityThread.access$600(ActivityThread.java:130) 08-02
> 01:59:07.288: E/AndroidRuntime(1569): at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
> 08-02 01:59:07.288: E/AndroidRuntime(1569): at
> android.os.Handler.dispatchMessage(Handler.java:99) 08-02
> 01:59:07.288: E/AndroidRuntime(1569): at
> android.os.Looper.loop(Looper.java:137) 08-02 01:59:07.288:
> E/AndroidRuntime(1569): at
> android.app.ActivityThread.main(ActivityThread.java:4745) 08-02
> 01:59:07.288: E/AndroidRuntime(1569): at
> java.lang.reflect.Method.invokeNative(Native Method) 08-02
> 01:59:07.288: E/AndroidRuntime(1569): at
> java.lang.reflect.Method.invoke(Method.java:511) 08-02 01:59:07.288:
> E/AndroidRuntime(1569): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
> 08-02 01:59:07.288: E/AndroidRuntime(1569): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 08-02
> 01:59:07.288: E/AndroidRuntime(1569): at
> dalvik.system.NativeStart.main(Native Method)
For some reason the method isn't being seen and yet the library is loading.... for what it's worth, I edited this code from here and pulled out what i needed. Thanx
In the source file you have:
Java_com_myproject_ndk_convert
But the javah has:
Java_com_myproject_MainActivity_convert
The log also says:
No implementation found for native Lcom/myproject/MainActivity;.convert:
Did you mean to write:
Java_com_myproject_MainActivity_convert