Ad

Ndk-build Not Compiling The Lib.so Files

- 1 answer

im building native code for android from command line via cd <project> ndk-build but when i run it it outputs nothing can be done for 'all' im using code from HelloJni sample, and if i import the the sample and compile it everything works fine.

activity

public class MainActivity extends Activity 
{
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        Log.i("DEBUG", stringFromJNI());
        setContentView(new MySurfaceView(this));
    }

    public native String stringFromJNI();

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

nativemain.c

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

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

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := nativemain
LOCAL_SRC_FILES := nativemain.c

include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_ABI := armeabi

Thank you so much for you guys and gals help!!

UPDATE 1: i refreshed the project and ran ndk-build again and work, but i received a UnsatisfiedLinkError exception on run time. Im using BlueStack as my emulator.

enter image description here

Ad

Answer

Try removing the "Application.mk" as it's not required for single-ndk-module applications (and the hello-jni doesn't have one)

Ad
source: stackoverflow.com
Ad