android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.library.spp"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
//在BuildConfig类中创建一个名为APPID的常量
buildConfigField "String", "APPID", "\"" + APPID + "\""
//修改 manifest 预制的对应参数 UID、CID、PID
manifestPlaceholders = [UID: UID,
CID: CID,
PID: PID,]
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
applicationVariants.all {
variant ->variant.outputs.each {
output ->def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "${variant.productFlavors[0].name}_" + UID + ".apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
//配置资源路径……这个可以参考下把eclipse项目转成studio项目时生成的Build.gradle文件
sourceSets {
main {
java.srcDirs = ['src/main/java']
}
pushDebug {
java.srcDirs = ['src/pushDebug/java']
manifest.srcFile 'src/pushDebug/AndroidManifest.xml'
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
productFlavors {
pushDebug {
}
pushRelease {
}
pushOverseas {
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name: 'analytics_for_c-des-1.1', ext: 'aar')
//pushDebug渠道编译pp目录下的internal渠道
pushDebugCompile project(path: ':pp', configuration: 'internalRelease')
pushReleaseCompile project(path: ':pp', configuration: 'internalRelease')
//pushRelease渠道编译pp目录下的overseas渠道
pushOverseasCompile project(path: ':pp', configuration: 'overseasRelease')
compile project(':push')
}
Build.gradle的妙用<一>
最新推荐文章于 2024-09-03 18:14:10 发布