Created
September 19, 2017 09:03
-
-
Save mr-wind/472bf98b582a4c61e06ad22318092362 to your computer and use it in GitHub Desktop.
较完整的一份gradle配置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
//加载本地签名 | |
def keystorePropertiesFile = rootProject.file("local.properties") | |
def keystoreProperties = new Properties() | |
keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) | |
android { | |
signingConfigs { | |
ExampleSign { | |
keyAlias keystoreProperties['keyAlias'] | |
keyPassword keystoreProperties['keyPassword'] | |
storeFile file(keystoreProperties['storeFile']) | |
storePassword keystoreProperties['storePassword'] | |
} | |
} | |
compileSdkVersion 25 | |
buildToolsVersion '25.0.0' | |
defaultConfig { | |
applicationId 'com.example.app' | |
minSdkVersion 19 | |
targetSdkVersion 21 | |
multiDexEnabled true | |
versionCode rootProject.ext.versionCode | |
versionName rootProject.ext.versionName | |
} | |
buildTypes { | |
debug { | |
//开启调试 | |
debuggable = true | |
//后缀 | |
applicationIdSuffix '.posdev' | |
//app名称 | |
manifestPlaceholders = [ali_push_appkey : "2*****6" | |
, ali_push_appsecret: "c********************************1"] | |
} | |
release { | |
//关闭debug | |
debuggable false | |
//后缀 | |
applicationIdSuffix '.pos' | |
//app名称 | |
manifestPlaceholders = [ali_push_appkey : "2*****3" | |
, ali_push_appsecret: "c********************************0"] | |
// //压缩资源(未使用的资源,不会编译进去) | |
// shrinkResources true | |
// //压缩代码,是否使用混淆 | |
// minifyEnabled false | |
// //混淆规则文件 | |
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
signingConfig signingConfigs.ExampleSign | |
} | |
} | |
sourceSets { | |
main { | |
jniLibs.srcDirs = ['libs'] | |
} | |
} | |
//打包自动命名 | |
android.applicationVariants.all { variant -> | |
variant.outputs.each { output -> | |
output.outputFile = new File(output.outputFile.parent, | |
defaultConfig.applicationId | |
+ (buildType.properties.containsKey("applicationIdSuffix") ? buildType.properties.get("applicationIdSuffix") : "") | |
+ "_" + defaultConfig.versionName + ".apk"); | |
} | |
} | |
} | |
repositories { | |
mavenCentral() | |
flatDir { | |
dirs 'aars' | |
} | |
maven { | |
url "https://jitpack.io" | |
} | |
} | |
dependencies { | |
compile fileTree(include: ['*.jar'], dir: 'libs') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment