Import third-party class libraries in Android studio

Source: Internet
Author: User

Often see some handy frameworks on GitHub, but there's always a lot of trouble with how a novice can import on Android studio, simply to look at how the third-party class library is imported on Android studio.

As an example of a simple textviewui control with a water-wave effect that I saw on GitHub, GitHub address: Https://github.com/RomainPiel/Tianic. First use the Git tool to clone it down or download its zip file and unzip it.

In Android studio, new project Githubsample,android Studio imports modules and third-party class libraries from File->new->importmodule.

Let's take a look at what's in the tianic.

There are self-contained examples and library libraries, of course, we want to be library libraries, for want to know how to use the can also be imported with sample, this can be changed in the Tianic directory settings.gradle.

The contents of the Settings.gradle file are as follows:

If you do not want to import sample, remove the following, here we import the example. Many times the direct import down of the third-party class library may encounter various problems, in tianic as an example, the following problem occurs in the direct import:

Say what Runproguard () method can not find, internet a check to know that the new version of Gradle has not supported the Runproguard () method corresponding use minifyenabled instead, So should be the sample and the library under the Build.gradle Runproguard replaced minifyenabled.

Sync again after change

Found that there was an error.

That is because my SDK does not have 19.0.1 version of the build Tool, either download the version of the Buildtool or in the sample and library under the Build.gradle to your application to use the version number, change before:

Do not know the version number that your app uses can be viewed in the Build.gradle under your application

Change the corresponding place in the build.gradle of the sample and the library to be shown, then sync

Found that there will be errors, such as what the resources can not find the error depends on the compiled dependent files, see the sample and the library under the Build.gradle file

Check the Build.gradle file under your app again

Discover a different version, change it to the version you used in your app, and then sync finds that there are no errors before you can use the frame in your app. Point to Project Structure first

Add library dependencies under your application's dependencies (Dependencies) and select the class library you want to use under module dependency.

This allows you to use it and add it in the main layout.

The main activity is as follows:

Operating effect:

In front of the step by step where the wrong to change where, the best way is not to import Android Studio will need to import the corresponding files of the class library to make changes, and then to briefly review, Select whether to import an example demo in the directory where the class library is located, and change the local version of the arrows in the Build.gradle file in the class library directory to the version of your project Settings.gradle.

Change the version number of the gradle/wrapper/gradle-wrapper.properties arrow in the Class Library directory to the version you are using for your project.

Change the corresponding version number in the Build.gradle file under the required library directory (not including the class Library Directory of sample) (Import the sample under Sample, Build.gradle also make corresponding changes), so that the import before the change to import a little bit faster error will be less, the other root It is prompted to do so.










Import third-party class libraries in Android studio

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.