Buildscript{//Set script run environment repositories {//Support Java Dependent Library Management (MAVEN) for Project Dependency mavencentral ()}Dependenciesthe definition of the {//dependent package. Support Maven/ivy, remote, local library, also support single file, if the MAVEN library is defined previously repositories{} , use Maven dependency//When only need to follow the similar com.android.tools.build:gradle:2.1 , Gradle will automatically download the corresponding dependencies to the remote library, is to create Gradle version classpath ' com.android.tools.build:gradle:2.1.0 ' } for Studio} Apply plugin:' Android 'Declaring the build project type Android{//Set parameters for compiling Android project Compilesdkversion } can be used in the project's Build.gradleApply plugin: ' com.android.application '//Description module type, com.android.application for program, Com.android.library for library
Android {
Compilesdkversion 22//Compiled SDK version
Buildtoolsversion "22.0.1"//Compiled Tools version
Defaultconfig {//default configuration
ApplicationID "Com.ding.app"//package name of the application
Minimum version supported by Minsdkversion 8//
Target version supported by Targetsdkversion 19//
Versioncode 52//Version number
Versionname "3.0.1"//Version Name
}
sourcesets {//directory pointing to Configuration
Main {
Manifest.srcfile ' androidmanifest.xml '//Specify Androidmanifest file
Java.srcdirs = [' src ']//specify the source directory
Resources.srcdirs = [' src ']//specify the source directory
Aidl.srcdirs = [' src ']//specify the source directory
Renderscript.srcdirs = [' src ']//specify the source directory
Res.srcdirs = [' res ']//specify resource Directory
Assets.srcdirs = [' Assets ']//Specify assets Directory
Jnilibs.srcdirs = [' Libs ']//specify LIB library directory
}
Debug.setroot (' build-types/debug ')//Specify the path to debug mode
Release.setroot (' build-types/release ')//Specify the path to release mode
}
Signingconfigs {//Signature configuration
Release {//release signature configuration
StoreFile file ("Fk.keystore")//Key files path
Storepassword "123"//Key file password
Keyalias "FK"//key Alias
Keypassword "123"//key password
}
Debug {version//debug signature configuration
StoreFile file ("Fk.keystore")
Storepassword "123"
Keyalias "FK"
Keypassword "123"
}
}
buildtypes {//build type
Release {//Publish
minifyenabled true//Confused Open
Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' proguard-project.txt '//Specify obfuscation rules file
Signingconfig signingconfigs.release//Setting up signature information
}
Debug {//debug
Signingconfig Signingconfigs.release
}
}
packagingoptions {
Exclude ' meta-inf/asl2.0 '
Exclude ' meta-inf/license '
Exclude ' meta-inf/notice '
Exclude ' meta-inf/manifest. MF '
}
lintoptions {
Abortonerror false//lint time to stop error escalation, to prevent the compilation of inexplicable failure
}
}
dependencies {
Compile Filetree (dir: ' Libs ', exclude: [' Android-support*.jar '], include: [' *.jar '])//project file Dependency--(local dependency) compile the. jar file in the Lib directory
Compile project (': Easylink ')//compile additional projects
Compile ' com.nostra13.universalimageloader:universal-image-loader:1.9.3 '//compiling third-party open source libraries from Jcenter
}
Multi-channel packaging
For multi-channel packages, the Android plugin provides aProduct Flavor{}Configuration for multi-channel packaging.
productflavors {playstore {packagename=' com.ding.app.playstore '}hiapk {packagename=' com . ding.app.hiapk}}
This is used in situations where the channel is different and requires a different package name.
If you use friends, Baidu, or 360 channels, you need to add some of the configuration items that the SDK needs to join in Androidmanifest.xml.then you need a fewAndroidmanifest.xml to differentiate the different channels. So in the build.gradle of the project Sourcesets do the configuration Sourcesets {main {manifest.srcfile ' androidmanifest.xml ' java.srcdirs = [ ' src '] resources.srcdirs = [ ' src '] aidl.srcdir s = [ ' src '] renderscript.srcdirs = [ ' src '] res.src Dirs = [ ' res '] assets.srcdirs = [ ' assets '] } hiapk {manifest.srcfile ' hiapk/androidmanifest.xml ' } playstore {ma Nifest.srcfile " playstore /androidmanifest.xml ' " span class= "cell" >
} instrumenttest.setroot ( ' tests ')
So you can get it done.