Android Studio Import third-party class library source code and JAR package

Source: Internet
Author: User

Create a new Android project with the following project structure:

1, add the third-party library source code

First, the third-party class library is checked into the same directory as the app sibling:

After that, add the compiled code under Build.gradle (MOUDULE:APP): Add the import code in Setings.gradle

Add later (a new module can be added)

Then delete it, and the build.gradle of the third party will be generated automatically.

As below, it is done.

Apply plugin:'com.android.library'Android {compilesdkversion -buildtoolsversion"25.0.2"Defaultconfig {minsdkversion thetargetsdkversion -Versioncode1Versionname"1.0"Testinstrumentationrunner"Android.support.test.runner.AndroidJUnitRunner"} buildtypes {release {minifyenabledfalseproguardfiles Getdefaultproguardfile ('Proguard-android.txt'),'Proguard-rules.pro'}}}dependencies {compile filetree (include: ['*.jar'], dir:'Libs') Androidtestcompile ('com.android.support.test.espresso:espresso-core:2.2.2', {Exclude group:'Com.android.support', module:'support-annotations'}) Compile'com.android.support:appcompat-v7:25.1.0'Testcompile'junit:junit:4.12'Compile files ('Libs/ksoap2.jar')}

2. Import Jar Package

Put it directly in the App/libs directory and add the compiled code under Build.gradle (Moudule:app):

Or:

Select Right click to select Add as Libariy .... Can

The preceding line of code is automatically generated

Complete!

"Welcome to Reprint"


Reprint please indicate the source music study

Android Studio Import third-party class library source code and JAR package

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.