Android Jni (Java Native Interface) Notes

Source: Internet
Author: User

First, a question is recorded about how to generate a header file with Javah.

Always prompt "Unable to access android.app.Activity", online check said to specify the location of Android.jar, can be specified in Classpath, can also be specified directly in the command. Under Windows both have tried, neither. So I installed Ubuntu. Pretending Ubuntu is a hassle, and initially wanted to use Wubi to install under Windows, failed. Later, a certain launcher was used to install the hard disk. There is also the size of the allocation swap, root directory/,home directory: It's really a layman. After the installation of a try, as if still not.

Again Baidu. Find the answer on the csdn. According to the 11 floor of the link, to write this:

Javah-classpath bin/classes-bootclasspath/home/larry/adt-bundle-linux-x86-20140702/sdk/platforms/android-20/ android.jar-d JNI com.example.hellojni.MainActivity

-classpath followed by the bin/classes specified is the path of class, here I created a HELLOJNI project, the package name is Com.example.hellojni, There is an activity is mainactivity, I am in the Hellojni directory to execute the above command, so with bin/classes to specify the class directory;

-bootclasspath I guess it's a parameter that directs the Android.jar of the back. A lot of answers were not mentioned before. Most are directly followed by a colon on the Android.jar path, followed by the class's address.

-D JNI means to place the generated H file in the Jni folder of the root directory.

Another way, according to the 12 floor of the argument, I also tried to add Android.jar to Classpath, no, or prompt cannot access android.app.Activity, maybe I add classpath way wrong? It's unclear, not to the whole.

Here's the picture:

Start learning JNI again below.

----------------------------------------------------------------------------------

Find a piece of this person's notes, think well written, just follow his to try it.

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.