Guo Xiaoxing
Weibo: Guo Xiaoxing's Sina Weibo
Email:[email protected]
Blog: http://blog.csdn.net/allenwells
Github:https://github.com/allenwell
This article explains how to add jar, module, and so libraries to Android studio.
Dependency configuration for a jar package
First use the shortcut key ctrl+alt+shift+s to open the configuration of the current project, as shown in:
1.1 Direct Search method
Click +->library Dependency to select the libraries you want to add as shown in the search.
1.2 Libs Addition method
Copy the library files directly to the Libs directory, and if there is no new one, as shown in:
Note: The Project Libs catalog for Eclipse import is under the root directory.
1.3 Gradle Addition method
We can also configure the library dependencies directly in the module Build.gradle, as shown in:
Dependent configuration of two module
Add the module that the project relies on, as shown in:
Dependency configuration of the three so libraries
Create the appropriate directory according to the CPU type, put it in the so library, and then copy the directory to the Libs directory, as shown in:
Then add the following to the Build.gradle in module, as shown in:
After the so library link succeeds, a Jnilibs folder is generated next to the Src/main directory.
This is how the library is imported, and since the previous projects were developed based on Eclipse, here's a bit of an introduction to migrating the Eclipse project to Android Studio.
Export from eclipse
As shown in the following:
- Upgrade your ADT plugin version to more than 22.0.
- In Eclipse, select File–>export.
- In the pop-up export window, open the Android folder and select "Generate Gradle Build Files".
- Select the items you want to import into Android studio and click Finish.
The exported project will be in the same directory as the original project, overwriting the original and adding a file called Build.gradle, which will be read first when importing Android studio.
Import to Android Studio
As shown in the following:
- In Android Studio, first turn off your current open project.
- On the Welcome screen, click Import Project (note: You can also select Import Project directly from the menu)
- Select the project you exported in Eclipse, expand the directory, click the Build.gradle file, and then OK
- In the following pop-up dialog, you will be asked to select the Gradle configuration and select Use Gradle wrapper. (Note: You can also customize the gradle of your own machine)
If you do not have a grade build file, you can also import a normal Android project into Android Studio, which will use the existing ant Build. However, in order to better use the functionality and build variables, it is strongly recommended that you generate the Gradle file from the ADT plug-in before importing into Android Studio.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Android Studio Discovery Road Series" VI: Android Studio Add dependency