Android eclipse JNI calls the. So file to load

Source: Internet
Author: User
Android eclipse JNI calls the. So file to load

  

Http://blog.sina.com.cn/s/blog_4d0afbdb0100m7y7.html

Background: compiled in eclipse for Android projects. put the so file under libs \ armeabi. the so file can be packaged into the APK file. After the APK is installed on the mobile phone, it will be stored in libs \ armeabi. the so file should be decompressed to/data/. Here is the package name of your project (such as COM. first. second)/lib.

Question: I wrote a test Android JNI app ,. so has been put in libs \ armeabi and can be seen from the compiled APK. so has been packaged in (decompress the APK file, which should contain the Lib folder) but in/data/COM. test. there is no corresponding under test/lib. so file

Solution: it turned out to be my. so is not named according to android standard ,. the so name must have the 'lib' prefix. Otherwise, when the APK is decompressed/installed on the mobile phone, the libs \ armeabi files will not be downloaded. so copy to/data/COM. test. test/lib. Originally, the so name I used was jnitest. So. Changed to libjnitest. So and everything went fine.

Supplement:
A) You must remove the Lib prefix system. loadlibrary ("jnitest") when calling with loadlibrary ");
B) when using the load command, you need to write the full path name and cannot remove the Lib prefix. Because it is used as a system for reading common files. load ("/data/COM. test. test/libjnitest. so ");

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.