Android Studio development-reference jar and so files

Source: Internet
Author: User

Author: Wang Xianrong
Recently, I was a beginner in Android development. Because I have never used JAVA before, I have to start from the very beginning with the basic syntax. How to reference jar and so files when trying to use the Baidu speech recognition engine. After several attempts at GOOGLE, I found a simple method, which is described as follows.
I. Reference jar files
1. copy and paste the jar file to the libs directory of the app;
2. Right-click the jar file and click "Add As Library" in the pop-up menu to Add the jar file to the project As a class Library;
3. Select the specified class library.
NOTE: If steps 2 and 3 are not executed, the jar file does not work and cannot be referenced using the import Statement.


Ii. Reference The so file
There are many methods to reference so files on the Internet, most of which are very troublesome. I found a simple method in KYLE THIELK's blog.
1. Create a directory named "jniLibs" in the "src/main" directory;
2. copy and paste the so file to the "jniLibs" directory.
Note: If the so file is not referenced, it may fail to load the class library during program execution. The following DEBUG prompt appears:
Java. lang. UnsatisfiedLinkError: Couldn't load library xxxx from loader dalvik. system. PathClassLoader


3. Thanks and download the source code
Thank you for reading this article and hope to help you.
The source code is an example of using the Baidu speech recognition engine. Click here to download it.
Note: 1. the Android Studio version used in this article is 0.4.6;
2. I changed the API KEY and security KEY at will. You need to replace it with the KEY you applied for to run properly;
3. url: http://www.kylethielk.com/blog/include-native-so-library-in-apk-with-android-studio/

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.