12 practical Android skills: How to import a third-party class library to Android Studio

Source: Internet
Author: User

12 practical Android skills: How to import a third-party class library to Android Studio

When a netizen's XMPP code is transferred from ADT to AS, it finds that it uses a third-party class library, the source code is placed under lib, and the project is directly imported in, third-party class libraries are not automatically imported in. It seems that you need to do it yourself.

The directory structure of the project is as follows:

XMPP$ lsapp    build.gradle  gradlew      import-summary.txt  XMPP.imlbuild  gradle        gradlew.bat  local.properties    settings.gradle

Copy the third-party source code qqEmoji-lib to this directory and modify settings. gradle to add this lib:

include ':app',':qqEmoji-lib'

Modify build. gradle in the app and add it to dependencies:

dependencies {    compile project(':qqEmoji-lib')    ...

Create the build. gradle file under qqEmoji-lib. For details, refer to the following:

apply plugin: 'android-library'android {    compileSdkVersion 19    buildToolsVersion "21.1.2"    defaultConfig {        minSdkVersion 8        targetSdkVersion 18    }    sourceSets {        main {            manifest.srcFile 'AndroidManifest.xml'            java.srcDirs = ['src']            resources.srcDirs = ['src']            aidl.srcDirs = ['src']            renderscript.srcDirs = ['src']            res.srcDirs = ['res']        }    }}dependencies {    compile 'com.android.support:appcompat-v7:19.1.0'    //compile 'com.android.support:support-v4:19.1.0'}

For configuration content of gradle, see the second link.

The project structure is as follows:

At this time, the compilation is successful. The import is successful!

Refer:
Http://www.cnblogs.com/neozhu/p/3458759.html
Http://www.open-open.com/lib/view/open1415793464648.html

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.