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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:50:31+00:00 2026-06-08T15:50:31+00:00

I am writing a very simple application following the guidelines in this tutorial .

  • 0

I am writing a very simple application following the guidelines in this tutorial.

I try to run my application and it fails while opening. The C code written has compiled using ndk-build.

Here is the Java Code :

package com.example.ndktest;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.support.v4.app.NavUtils;

public class MainActivity extends Activity {


    private Button button;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i( "MainActivity", "beginning of onCreate()" );
        setContentView(R.layout.activity_main);

        button = (Button) findViewById( R.id.button1 );
        button.setOnClickListener( new OnClickListener( ) {

        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            helloLog( "This will log to LogCat" );
        }

        });
    }
    private native void helloLog( String logThis );

    static {
        System.loadLibrary( "ndk1" );
    }

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

Here is the C code :

#include <jni.h>
#include <string.h>
#include <android/log.h>

#define DEBUG_TAG "NDK_AndroidNDK1SampleActivity"

void Java_com_example_ndktest_MainActivity_helloLog( JNIEnv * env, jobject this, jstring logThis )
{
    jboolean isCopy;
    const char * szLogThis = (*env)->GetStringUTFChars( env, logThis, &isCopy );

    __android_log_print( ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:LC: [%s]", szLogThis );

    (*env)->ReleaseStringUTFChars( env, logThis, szLogThis );
}

Here is the MakeFile:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)  

LOCAL_LDLIBS := -llog  

LOCAL_MODULE    := ndk1  
LOCAL_SRC_FILES := native.c  

include $(BUILD_SHARED_LIBRARY)

Here is the XML file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:padding="@dimen/padding_medium"
        android:text="@string/hello_world"
        tools:context=".MainActivity" />

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:text="Click Here to Log" />

</RelativeLayout>

Here is the AndroidManifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ndktest"
    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/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

Here is a picture of my environment in Eclipse :

enter image description here

EDIT :

Found out the LogCat did show things, but they were being hidden by filters…Still can’t figure out the problem. Here’s the LogCat:

07-30 15:22:31.718: E/AndroidRuntime(2589): FATAL EXCEPTION: main
07-30 15:22:31.718: E/AndroidRuntime(2589): java.lang.ExceptionInInitializerError
07-30 15:22:31.718: E/AndroidRuntime(2589):     at java.lang.Class.newInstanceImpl(Native Method)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at java.lang.Class.newInstance(Class.java:1409)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.os.Looper.loop(Looper.java:130)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at android.app.ActivityThread.main(ActivityThread.java:3683)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at java.lang.reflect.Method.invokeNative(Native Method)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at java.lang.reflect.Method.invoke(Method.java:507)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at dalvik.system.NativeStart.main(Native Method)
07-30 15:22:31.718: E/AndroidRuntime(2589): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load ndk1: findLibrary returned null
07-30 15:22:31.718: E/AndroidRuntime(2589):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at java.lang.System.loadLibrary(System.java:554)
07-30 15:22:31.718: E/AndroidRuntime(2589):     at com.example.ndktest.MainActivity.<clinit>(MainActivity.java:38)
07-30 15:22:31.718: E/AndroidRuntime(2589):     ... 15 more
07-30 15:22:31.718: W/ActivityManager(1136):   Force finishing activity com.example.ndktest/.MainActivity

EDIT 2 :

Here is the picture of my cygwin terminal after I call ndk-build :

enter image description here

  • 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-08T15:50:33+00:00Added an answer on June 8, 2026 at 3:50 pm

    Most probably the library libndk1.so couldn’t be loaded by your Activity. Are you sure libndk1.so builds fine?

    by: java.lang.UnsatisfiedLinkError: Couldn't load ndk1: findLibrary returned null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a very simple HTML code which is listed below. Written in
I'm writing a very simple web service, written in Python and run as CGI
I am writing a very simple application, for the iPhone. Unfortunately I am really
I'm writing a very Simple Chat Application and would like to know how to
I'm currently writing a very simple JavaFX application which will hopefully display information from
I am writing a very simple application which allows one to change the temperature.
I'm writing a very simple application in Javafx where there is a single button
I'm working on writing a very simple client/server application as an excuse to start
I'm writing very simple application. It is supposed to download files from internet. I
I'm writing a very simple web application in ASP.NET MVC 2.0 which is used

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.