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 9165599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:56:40+00:00 2026-06-17T14:56:40+00:00

I am trying to build android application using native code so i want to

  • 0

I am trying to build android application using native code so i want to test if ndk runs successfully.When i try to run my first hello world project
log cat says,

01-21 23:30:06.780: E/AndroidRuntime(939): FATAL EXCEPTION: main
01-21 23:30:06.780: E/AndroidRuntime(939): java.lang.UnsatisfiedLinkError: 
Native method not found: com.example.ndktesting.MainActivity.invokeNativeFunction:()Ljava/lang/String;

I checked some stackoverflow answers but could not find my answer.Here is my code for java and c.I am using android ndk r8d version.

//ndktest.c

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

extern "C"{
    JNIEXPORT jstring JNICALL   Java_com_example_ndktesting_ndktest_MainActivity_invokeNativeFunction(JNIEnv* env, jobject  thiz)
};

JNIEXPORT jstring JNICALL   Java_com_example_ndktesting_ndktest_MainActivity_invokeNativeFunction(JNIEnv* env, jobject  thiz){
    return (*env)->NewStringUTF(env, "Hello from native code!");
}

Here is my MainActivity java code:

package com.example.ndktesting;

public class MainActivity extends Activity {    
    //declare the native code function - must match ndktest.c
    private native String invokeNativeFunction();

    public native String  unimplementedinvokeNativeFunction();

    // load the library - name matches jni/Android.mk 
    static {
        System.loadLibrary("ndktest");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // this is where we call the native code
        String hello = invokeNativeFunction();

        new AlertDialog.Builder(this).setMessage(hello).show();
    }
}

Android make file code:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

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

include $(BUILD_SHARED_LIBRARY)
  • 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-17T14:56:41+00:00Added an answer on June 17, 2026 at 2:56 pm

    Your package/class names do not match.

    JNIEXPORT jstring JNICALL   Java_com_example_ndktesting_ndktest_MainActivity_invokeNativeFunction(JNIEnv* env, jobject  thiz)
    

    Would be a method in the class

    com.example.ndktesting.ndktest.MainActivity
    

    However your actual code

    package com.example.ndktesting;
    
    public class MainActivity extends Activity 
    

    causes it to look for

    com.example.ndktesting.MainActivity.invokeNativeFunction
    

    without the “ndktest”

    Once you make the names match it should either work, or expose the next issue.

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

Sidebar

Related Questions

I'm trying to debug some native code I built using the android ndk-build script
I'm trying to debug an Android application with native code using ADT 20.0.3 on
I'm trying to build a simple Android application using NDK. Here are the contents
I am trying to build an Android Soft keyboard application using avail code at
I am trying to write a simple Android application using the NDK and C++.
I'm currently trying to build an android application using the Android 4.1.2 Java libraries.
I'm trying to build an OCR application on Android using Tesseract, but when I
I am trying to build an Android application and want a menu on it.
I am trying to create .so files using Cygwin for my Android ndk application.
Trying to build a simple helloWorld android/java application with jni c code. I am

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.