Note that there are some explanatory texts on larger screens.

plurals
  1. PONDK Native Class not found Error
    primarykey
    data
    text
    <p>I've been trying to figure out why I'm getting an error stating the method can't be found, but everything seems to be in order (at least the things that would cause this error).</p> <p>My Android class:</p> <pre><code>package com.liamw.root.androididchanger; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class DebugUserActivity extends Activity { Button button; TextView logcat; static { System.loadLibrary("sqlite"); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.debug); button = (Button) findViewById(R.id.button1); logcat = (TextView) findViewById(R.id.textView1); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { runSQL("example.sqlite3", "SELECT Value FROM MyTable"); } }); /*try { Runtime.getRuntime().exec("logcat -c").waitFor(); Process process = Runtime.getRuntime().exec("logcat -v long *:*"); BufferedReader reader = new BufferedReader(new InputStreamReader( process.getInputStream())); while (true) { String nextLine = reader.readLine(); logcat.setText(logcat.getText().toString() + "\n" + nextLine); } } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }*/ } public native void runSQL(String path, String query); } </code></pre> <p>The native file (idchanger.c):</p> <pre><code>#include &lt;jni.h&gt; #include &lt;errno.h&gt; #include &lt;string.h&gt; #include &lt;stdio.h&gt; #include &lt;android/log.h&gt; #include &lt;../sqlite3.c&gt; #include &lt;../sqlite3.h&gt; #ifndef LOG_TAG #define LOG_TAG "idchanger.c" #endif #define SQLITE_NDK_VFS_NAME "name" #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) void Java_com_liamw_root_androididchanger_DebugUserActivity_runSQL(JNIEnv * env, jobject this, jstring query, jstring path) { sqlite3 *db; sqlite3_stmt *stmt; jboolean isCopy; const char * rQuery = (*env)-&gt;GetStringUTFChars(env, query, &amp;isCopy); const char * rPath = (*env)-&gt;GetStringUTFChars(env, path, &amp;isCopy); if (sqlite3_open_v2(rPath, &amp;db, SQLITE_OPEN_READWRITE, SQLITE_NDK_VFS_NAME) == SQLITE_OK) { LOGI("Database opened OK"); if (sqlite3_prepare_v2(db, rQuery, -1, &amp;stmt, NULL) == SQLITE_OK) { LOGI("Table opened OK"); int err; while ((err = sqlite3_step(stmt)) == SQLITE_ROW) { LOGI("Value: %s\n\n", sqlite3_column_text(stmt, 0)); } if (err != SQLITE_DONE) { LOGE("Query failed: %s\n", sqlite3_errmsg(db)); } LOGI("Finalise..."); sqlite3_finalize(stmt); } else { LOGE("Could't execute query: %s\n", sqlite3_errmsg(db)); } } else { LOGE("Can't open database: %s\n", sqlite3_errmsg(db)); } LOGI("Close connection"); sqlite3_close(db); } </code></pre> <p>The error:</p> <pre><code>09-07 20:48:07.793: E/AndroidRuntime(21193): FATAL EXCEPTION: main 09-07 20:48:07.793: E/AndroidRuntime(21193): java.lang.UnsatisfiedLinkError: Native method not found: com.liamw.root.androididchanger.DebugUserActivity.runSQL:(Ljava/lang/String;Ljava/lang/String;)V 09-07 20:48:07.793: E/AndroidRuntime(21193): at com.liamw.root.androididchanger.DebugUserActivity.runSQL(Native Method) 09-07 20:48:07.793: E/AndroidRuntime(21193): at com.liamw.root.androididchanger.DebugUserActivity$1.onClick(DebugUserActivity.java:34) 09-07 20:48:07.793: E/AndroidRuntime(21193): at android.view.View.performClick(View.java:4211) 09-07 20:48:07.793: E/AndroidRuntime(21193): at android.view.View$PerformClick.run(View.java:17362) 09-07 20:48:07.793: E/AndroidRuntime(21193): at android.os.Handler.handleCallback(Handler.java:725) 09-07 20:48:07.793: E/AndroidRuntime(21193): at android.os.Handler.dispatchMessage(Handler.java:92) 09-07 20:48:07.793: E/AndroidRuntime(21193): at android.os.Looper.loop(Looper.java:137) 09-07 20:48:07.793: E/AndroidRuntime(21193): at android.app.ActivityThread.main(ActivityThread.java:5227) 09-07 20:48:07.793: E/AndroidRuntime(21193): at java.lang.reflect.Method.invokeNative(Native Method) 09-07 20:48:07.793: E/AndroidRuntime(21193): at java.lang.reflect.Method.invoke(Method.java:511) 09-07 20:48:07.793: E/AndroidRuntime(21193): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795) 09-07 20:48:07.793: E/AndroidRuntime(21193): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562) 09-07 20:48:07.793: E/AndroidRuntime(21193): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Everything seems to be in order to me, but what is the error?</p> <p>EDIT:</p> <p>Android.mk:</p> <pre><code>LOCAL_PATH := $(call my-dir) $(LOCAL_PATH)/../sqlite3.c: $(MAKE) -C $(@:%/sqlite3.c=%) sqlite3.c include $(CLEAR_VARS) LOCAL_LDLIBS := -llog -landroid LOCAL_MODULE := sqlite LOCAL_SRC_FILES := ../sqlite3.c idchanger.c LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_CFLAGS := -DSQLITE_THREADSAFE=1 include $(BUILD_STATIC_LIBRARY) </code></pre> <p>EDIT2:</p> <p>Aha! This is added to the logcat:</p> <pre><code>09-09 19:59:28.605: D/dalvikvm(9696): No JNI_OnLoad found in /system/lib/libsqlite.so 0x40e46360, skipping init </code></pre> <p>Edit 3: I just noticed that on a test app I made, there are some lines in the logcat stating that it attempted to load the library, and then the ndk library file...</p> <p>I don't see those lines here....</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.
 

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