joaoventura / pybridge

Reuse Python code in native Android applications
215 stars 56 forks source link

UnsatisfiedLinkError: No implementation found #11

Closed jbmlaird closed 6 years ago

jbmlaird commented 6 years ago

My first foray into the Android NDK so perhaps I'm doing this wrong, but having just changed the name of the package from com.jventura to com.randompkg and then changing pybridge.c to

JNIEXPORT jint JNICALL Java_com_randompkg_pybridge_PyBridge_start JNIEXPORT jint JNICALL Java_com_randompkg_pybridge_PyBridge_stop JNIEXPORT jint JNICALL Java_com_randompkg_pybridge_PyBridge_call

causes me to get this stack trace:

11-13 22:03:28.172 18981-18981/com.jventura.pyapp E/art: No implementation found for int com.randompkg.pybridge.PyBridge.start(java.lang.String) (tried Java_com_randompkg_pybridge_PyBridge_start and Java_com_randompkg_pybridge_PyBridge_start__Ljava_lang_String_2)
11-13 22:03:28.173 18981-18981/com.jventura.pyapp D/AndroidRuntime: Shutting down VM
11-13 22:03:28.174 18981-18981/com.jventura.pyapp E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: com.jventura.pyapp, PID: 18981
                                                                    java.lang.UnsatisfiedLinkError: No implementation found for int com.randompkg.pybridge.PyBridge.start(java.lang.String) (tried Java_com_randompkg_pybridge_PyBridge_start and Java_com_randompkg_pybridge_PyBridge_start__Ljava_lang_String_2)
                                                                        at com.randompkg.pybridge.PyBridge.start(Native Method)
                                                                        at com.randompkg.pyapp.MainActivity.onCreate(MainActivity.java:29)
                                                                        at android.app.Activity.performCreate(Activity.java:6672)
                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
                                                                        at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:154)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6123)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

PyBridge.java remains as:

package com.randompkg.pybridge;

import org.json.JSONObject;
import org.json.JSONException;

public class PyBridge {
...

Is there anything else I need to change?

jbmlaird commented 6 years ago

I had to run ndk-build again:

From the instructions: cd to app/src/main/jni, and run path/to/crystax/ndk-build

ZhangKuixun commented 5 years ago

@jbmlaird How to solve this problem?

mahendrarajdhami commented 5 years ago

i have run ndk-build and there are libcrystax, libpython3.5 and libpybridge in src/main/libs/armeabi-v7a & src/main/libs/x86 but still it's giving same error.

mahendrarajdhami commented 5 years ago

i fixed above issue by modifying jni/pybridge.c . we have to change JNICALL according to our package name