Ndk make: *** no rule can be created
$ Ndk/ndk-build
The above error is generally because Android. mk in your JNI file contains spaces that are not suitable.
There may be many reasons for this problem.
If this problem occurs, check the Android. mk file and remove all useless spaces.
========================================================== ======================================
Android Ubuntu JNI so error: Java. Lang. unsatisfiedlinkerror: stringfromjni
Hello-jni.c
The hello-jni.c file content is as follows:
# Include<String. h>
# Include<JNI. h>
JstringJava_com_gcx_ndkjni_hellondkjni_stringfromndkjni (
Jnienv *Env,Jobject thiz)
{
Return (*Env)-> Newstringutf (Env,
"Hello from ndk JNI! ");
}
Java_com_gcx_ndkjni_hellondkjni_stringfromndkjni
The method defined in your so library must be consistent with the package name in your Java Project (Note: In the ndkjni package of gcx package in the com package in Java code
The stringfromndkjni method can be called in the hellondkjni class ).
Java_com_example_test_hellojni_hellojni_stringfromjni (jnienv * ENV, jobject thiz)
Then you need to define a hellojni class named com. example. Test. hellojni, and then define the native method tringfromjni in the hellojni class. In this way, the corresponding function is found.
Then enable cygwin to re-compile:
Root @ hjm-H61M-DS2 :~ /Workspace/hellondkjni # $ ndk/ndk-build
The $ ndk command varies from person to person. For more information, see the Environment Variable Design in. basrch.
There will be two more folders in the project. You don't have to worry about it.
Finally
Static{
System.Loadlibrary("Hello-JNI ");
}
The Hello-JNI inside represents the libhello-jni.so
Confirm the package name here.