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