"Android Studio Discovery Trail Series" VI: Android Studio joins dependencies

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

List of "Android Studio Discovery Road Series" chapters

One of the "Android Studio Discovery Trail Series": Android Studio begins
Android Studio Discovery Road Series II: Android Studio Software Installation
Android Studio Discovery Road Series III: Android Studio interface elements
Android Studio Discovery Trail Series: Android Studio shortcut keys
"Android Studio Discovery Road Series": Android Studio project creation
"Android Studio Discovery Trail Series" VI: Android Studio joins dependencies
"Android Studio Discovery Trail Series" VII: Android Project building System-Gradle

This article explains how to include jar, module, and so libraries in 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. For example, as seen in:

1.1 Direct Search method

Click +->library dependency, for example, select the libraries you would like to join with the search you see.

1.2 Libs Addition method

Copy the library files directly to the Libs folder, assuming you are not able to create a new one, for example, as seen in:

Note: The Projectlibs folder for Eclipse import is under the root folder.

1.3 Gradle Addition method

We are also able to configure the library's dependencies directly in the module Build.gradle, for example, as seen in:

Dependent configuration of two module

Join the module that project relies on, such as what you see:

Dependency configuration of the three so libraries

Create the corresponding folder according to the CPU type, put in so library, and then copy the folder to the Libs folder. For example, as seen in:

Then add the following to the Build.gradle in the module, for example, as seen in:

After the so library link succeeds, a Jnilibs folder is generated next to the Src/main folder.

These are the import methods that rely on libraries. Since the project was developed on the basis of eclipse. Here's how to move the Eclipse project to Android Studio.

Export from eclipse

For example, as seen in:

    1. Upgrade your ADT plugin version number to more than 22.0.
    2. In Eclipse, select File–>export.
    3. In the export form that pops up, 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 folder as the original project, overwriting the original same time, will add a file called Build.gradle, when importing Android studio will first read this file.

Import to Android Studio

For example, as seen in:

    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 that you exported in eclipse. Expand the folder and click the Build.gradle file. Then OK
    4. In the pop-up dialog box that follows. You will be asked to choose the Gradle configuration. Select the use Gradle wrapper. (Note: You can also define your own machine-installed gradle)

Suppose there is no grade build file. It is also possible to import an ordinary Android project into Android Studio, which will use the existing ant build. But in order to better use the post-function and make full use of build variables, it is strongly recommended to first generate the Gradle file from the ADT plugin and import it into Android studio.

"Android Studio Discovery Trail Series" VI: Android Studio joins dependencies

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.