Androidstudio Import the external library file, and the module reference in the project depends on

Source: Internet
Author: User

One: Import such as Baidu Map and other external classes.

Step: 1. Switch Androidstudio project display to project status display first

2. Then add the. jar file, place all the. jar files in the Libs folder (the Libs folder is under the project folder), and then right-click on the. jar file that you introduced and then tap Add as Library ... OK jar file introduced.

3. Add the. So file, under the project under the SRC directory under the main directory to create a new Jnilibs folder, and then connect the so file with his folder outside the entire copy to the Jnilibs folder (Note: So file does not exist directly under the Jnilibs folder, Need to be present in a file such as Armeabi, Jnilibs folder), after pouring the file into the file in the Build.gradle to add

sourcesets{
Main () {
Jnilibs.srcdirs = [' Libs ']
}
}
Code. Specifically put in the following location:

Apply plugin: ' Com.android.library '

Android {
Compilesdkversion 23
Buildtoolsversion "23.0.3"

Defaultconfig {
Minsdkversion 11
Targetsdkversion 23
Versioncode 1
Versionname "1.0"
}
Buildtypes {
Release {
Minifyenabled false
Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
}
}
sourcesets{
Main () {
jnilibs.srcdirs = [' Libs ']
}
}
}

dependencies {
Compile Filetree (dir: ' Libs ', include: [' *.jar '])
Testcompile ' junit:junit:4.12 '
Compile ' com.android.support:appcompat-v7:23.4.0 '
Compile files (' Libs/baidulbs_android.jar ')
}
You can now use the methods of the external classes.

Second: Reference the module of the same project as a dependency package
1. Select the module you want to use as the library. Select his build.gradle file to put the top code
Apply plugin: ' Com.android.application ' insteadApply plugin: ' Com.android.library '. Then delete the following code to the location:Android under the Defaultconfig under the ApplicationID "Frame.myc.com.mycframe". After deletion, the code is
Android {
Compilesdkversion 23
Buildtoolsversion "23.0.3"

Defaultconfig {
Minsdkversion 11
Targetsdkversion 23
Versioncode 1
Versionname "1.0"
}
Buildtypes {
Release {
Minifyenabled false
Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
}
}
sourcesets{
Main () {
Jnilibs.srcdirs = [' Libs ']
}
}
}

2. Add a dependency on the main file click File->project structure to the left of the module select your main project, then right click on the dependencies, click on the bottom or the + point to open after the three options to select module Dependency, select the Midule file you just modified as the library in the popup screen OK.

Androidstudio Import the external library file, and the module reference in the project depends on

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.