Getting Started with Android studio-referencing jars and so files

Source: Internet
Author: User

Recently started Android development, because never used Java before, even the basic grammar to start from scratch, so not very smooth. There was an issue with how to reference jar and so files when trying to use the Baidu speech recognition engine. After Google plus a number of attempts, found a relatively simple method, described below.
I. Referencing a JAR file
1. Copy and paste the jar file into the Libs directory of the app;
2. Right-click on the jar file and click "Add as Library" in the pop-up menu to add the jar file as a class library to the project;
3. Select the specified class library.
Note: If you do not perform step 2, 3, the jar file will not work and cannot be referenced using the import statement.


Ii. citation of so files
There are many ways to quote so files on the web, most of which are cumbersome, and find an easy way out of Kyle Thielk's blog.
1. Create a new directory named "Jnilibs" in the "Src/main" directory;
2. Copy and paste the so file into the "Jnilibs" directory.
Note: If the so file is not referenced, it may fail to load the class library when the program executes, with a debug prompt similar to the following:
JAVA.LANG.UNSATISFIEDLINKERROR:COULDN ' t load library xxxx from loader Dalvik.system.PathClassLoader


Third, thanks and source code download
Thank you for reading this article and hope to help you.
Source code is the use of Baidu speech recognition engine example, click here to download.
Note: 1. The version of Android Studio used in this article is 0.4.6;
2.API Key and security key I changed, you need to replace the key to your application to operate normally;
3. Reference website: http://www.kylethielk.com/blog/include-native-so-library-in-apk-with-android-studio/

Category: Android development

Getting Started with Android studio-referencing jars and so files

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.