Android Ubuntu JNI so error: Java. Lang. unsatisfiedlinkerror: stringfromjni ________ ndk make: *** No

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.