"Android Studio Discovery Road Series" VI: Android Studio Add dependency

Source: Internet
Author: User

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:

    1. Upgrade your ADT plugin version to more than 22.0.
    2. In Eclipse, select File–>export.
    3. In the pop-up export window, open the Android folder and select "Generate Gradle Build Files".
    4. 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:

    1. In Android Studio, first turn off your current open project.
    2. On the Welcome screen, click Import Project (note: You can also select Import Project directly from the menu)
    3. Select the project you exported in Eclipse, expand the directory, click the Build.gradle file, and then OK
    4. 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

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.