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 codeApply 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