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

  • Home
  • SEARCH
  • 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 8832137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:27:46+00:00 2026-06-14T08:27:46+00:00

I was trying out the Hello World programme on ndk/jni android. This is my

  • 0

I was trying out the Hello World programme on ndk/jni android.

This is my java Code:

package com.example.myndkapp;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends Activity {
    // load the library - name matches jni/Android.mk
    static {
        Log.d("TAG1","Before Load");
        System.loadLibrary("ndkfoo");
        Log.d("TAG2","After Load");
    }

    // declare the native code function - must match ndkfoo.c
    private native String invokeNativeFunction();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Log.d("TAG3","Set Content View Called");
        // this is where we call the native code
        try{
            String hello = invokeNativeFunction();
            Log.d("TAG4","InvokeFunc Called..");
            new AlertDialog.Builder(this).setMessage(hello).show();
        }catch(Exception e){
            e.printStackTrace();
        }


    }
}

The ndkfoo.c Code:

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

jstring Java_com_example_ndkfoo_MAinActivity_invokeNativeFunction(JNIEnv* env, jobject javaThis) {
  return (*env)->NewStringUTF(env, "Hello from native code!");
}

My Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# Here we give our module name and source file(s)
LOCAL_MODULE    := ndkfoo
LOCAL_SRC_FILES := ndkfoo.c

include $(BUILD_SHARED_LIBRARY)

My AndroidMainfest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myndkapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I get the error UnsatisfiedLinking Error and application force closes. Also, I get the no implementation found for native function.

  • 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-14T08:27:47+00:00Added an answer on June 14, 2026 at 8:27 am

    Your package name is not exactly same.change that in ndkfoo.c to

     #include <string.h>
      #include <jni.h>
    
      jstring Java_com_example_myndkapp_MainActivity_invokeNativeFunction(JNIEnv* env, jobject      javaThis) {
      return (*env)->NewStringUTF(env, "Hello from native code!");
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn Java now and this is the hello world program
I have this strange problem. I'm trying to write a simple Hello World java
I am trying out the basic hello world program on my LG Thrive phone
I'm trying out Visual Studio at the time. I created a simple hello world
I'm trying to do a simple hello world to test out embedding IronPython within
I am trying to invoke a simple Hello World Cobol program through java. The
Hello I am writing this program, and I am trying to figure out how
So I'm trying to just alert out my Hello from my php file, it's
Hello I been trying to figure out how to set up ASP.Net forms authentication
Hello stackoverflow community ! I am trying to figure out how to architect my

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.