Note that there are some explanatory texts on larger screens.

plurals
  1. POUnsatisfiedLinkError for native cpp function in Android app (ndk)
    primarykey
    data
    text
    <p>I am trying to run an easy Android ndk app in cpp, but I get UnsatisfiedLink Error for the Generate() function. </p> <p>Any help would be appreciated. I am quite fluent in c++, but my java is a little bit rusty. I have been trying a lot of tips from the web concerning naming, but so far no luck. Here are my files:</p> <p>native.cpp:</p> <pre><code>#include &lt;string.h&gt; #include &lt;jni.h&gt; jstring Java_com_optimuse_app_OptimuseAppActivity_generate(JNIEnv* env, jobject thiz){ return env-&gt;NewStringUTF("Hello from JNI !"); } </code></pre> <p>Android.mk:</p> <pre><code>LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := native LOCAL_SRC_FILES := native.cpp include $(BUILD_SHARED_LIBRARY) </code></pre> <p>I compile this with ndk-build and all goes well, it provides me with a libnative.so, that is located in the project directory. I use eclipse for the rest. </p> <p>OptimuseAppActivity.java:</p> <pre><code>package com.optimuse.app; import android.app.Activity; import android.widget.TextView; import android.os.Bundle; public class OptimuseAppActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText( generate() ); setContentView(tv); } public native String generate(); static { System.loadLibrary("native"); } } </code></pre> <p>And the automatically generated AndroidManifest.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.optimuse.app" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="15" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:hasCode="true"&gt; &lt;activity android:name="com.optimuse.app.OptimuseAppActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Thank you for any suggestions, been searching for a few hours now!</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.
 

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