Eclipse JNI Project migrating Android Studio related issues

Source: Internet
Author: User

Recently in the project migration, Eclipse on the project to use the JNI, need to transfer to Android studio, originally to JNI is not very understanding, this is more trouble, encountered various problems, the process is painful. But finally finished, the encounter problems recorded, at the same time can let people encounter related issues reference.

First of all, I was to copy and paste the files from Eclipse, in fact, it is not troublesome, mainly jni, directly pasted over is not possible, and in as on the re-generated so file is also unrealistic, because I jni knowledge is too poor, can only reluctantly still use the so file on Eclipse, This is more convenient, as long as the eclipse in the Libs folder, such as, armeabi-v7a, Armeabi folder copy down, and then in the main folder as the creation of the Jnilibs folder, and then paste it in, you can. This is the theory, but the real problem is just beginning.

Problem one: You can not use after getting over, has been error: Java.lang.UnsatisfiedLinkError:No implementation found for xxxxxxxxxxxxx .... It is probably not possible to find the implementation of the Jni method (native method), the detection method is not a problem, it must be so file problems. I often looked up the information and found that my new project's package name was changed, so the so file needs to be regenerated.

Workaround: Regenerate so file, put the Jniexport Jbytearray in the Jni file Jnicall Java_ Package Name _ Class Name _ Method name, instead of the one you are using now. (Note: It may be 1 or more places to change the #include后面的别改, which is required to generate so file reference)


Problem two: Unable to generate so file, do not make, research after discovery is dependent on the library to specify the absolute path has a problem.

Workaround: Modify the Android.mk file to change the path to the correct path for the library name in the library that is dependent on the. mk file.


Question three: Still can't generate so file, later found that different NDK version will also be affected, I use R13, later downloaded R10, can use.

Workaround: Try different versions of the NDK.


Problem four: So file generation, testing can be used, but later found that sometimes there will be that, java.lang.UnsatisfiedLinkError:No implementation found for xxxxxxxxxxxxx ....

Simply collapsed, and later found a lot of information.

Workaround, add a static code block to the activity that uses the so file static{

System.loadlibrary ("So file name"); For example: So file is libabc.so so when it's used, it's ABC.

}


Got a few days finally solved, hope to meet the same problem of people can refer to.


This article is from the "Mobile Platform Development" blog, make sure to keep this source http://liuxudong1001.blog.51cto.com/10877072/1885151

Eclipse JNI Project migrating Android Studio related issues

Related Article

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.