Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:54:05+00:00 2026-06-11T12:54:05+00:00

I am trying to run an easy Android ndk app in c, but I

  • 0

I am trying to run an easy Android ndk app in c, but I get UnsatisfiedLink Error for the stringFromJNI() function.

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:

hello-jni.c:

#include <string.h>
#include <jni.h>


jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return (*env)->NewStringUTF(env, "Hello from JNI !");
}

Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.c

include $(BUILD_SHARED_LIBRARY)

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.

NdkFooActivity.java :

package com.narola.Testndk;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

public class NdkFooActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ndk_foo);

        Log.i("comes at point","hay...");
        Log.d("value is : ",""+stringFromJNI());
    }

    public native String  stringFromJNI();
    public native String  unimplementedStringFromJNI();

    static {
        System.loadLibrary("hello-jni");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_ndk_foo, menu);
        return true;
    }
}

Thank you for any suggestions, been searching for a few hours now!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:54:06+00:00Added an answer on June 11, 2026 at 12:54 pm

    The problem is in the hello-jni.c file.
    You have method signature in c file is Java_com_example_hellojni_HelloJni_stringFromJNI else in your activity the package name is com.narola.Testndk.

    The method signature has format like Java_packagename_activityname_methodname (In package name (.)Dot will be replaced by underscore).
    In your case try like Java_com_narola_Testndk_NdkFooActivity_stringFromJNI

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to run a junit test I get the following error - java.lang.ClassCastException:
I figure this is very easy, but I am trying to run this command
I'm still trying to run my easyhook exercize. right now, i get this error:
I'm trying to get reportlab to run under Jython (2.5.2), but it fails to
i bet its pretty easy question , any way im trying to run a
I am trying to run a python script from R. Which is easy enough
Trying to run a self-hosted app on my Win 7 system, with little success.
Trying to run Jison unit tests, but the command fails. How do I fix
So this is probably an easy thing that I'm trying to do but I'm
I'm trying to run a query where two columns are not the same, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.