Android Studio: Add a function library from maven

Source: Internet
Author: User

Adding a 3rd party library to Android studio is not really a bother, it's just that there is no UI, so there's a need for some hands-on. Google is very optimistic about Android studio, so the UI should be supported soon. Before doing this, please add the library as follows.

Android Studio Core is IntelliJ, but in the encoding apk, he used Gradle. IntelliJ is a famous IDE, inside can refactor of things, it is worth to use to see, it has a UI can add library dependency. But the question is gradle,gradle. A somewhat similar build management system with MAVEN, Gradle's language is much more understood than Maven's XML and deserves to be studied. Now Android Studio has no UI to edit gradle, it's all about using pure text files, and it's not too difficult.

So, to add a new library from Maven repository, you need the following steps:

  • First come to http://search.maven.org/, use Search to find the library you want

    Let's take Gson for example today.

  • Open the Build.gradle of the main case

    For example, the top layer is exampleproject, this is container can contain each related sub-project, it has another Example this is the main project, Build.gradle is in the Example this record.

  • Add the following lines

    Repositories{Mavencentral()}Dependencies{Compile‘Com.Android.Support:Support-V4:13.0.+‘CompileGroup:‘com. Google. Code. Gson ' name:  gson ' version:  ' 2.2.4 ' compile files  ( ' libs/android-< span class= "n" >async-http-1.4.3 jar ' ) }         

    Among them compile group: ' Com.google.code.gson ', Name: ' Gson ', version: ' 2.2.4 ' is certainly the repository function from Maven Gson.

  • When Android Studio grabs the file, it will soon be discovered that there is a line in External libraries.






When these are done, you should be done.

Android Studio: Add a function library from maven

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.