apply plugin: 'com.android.application' Properties props = new Properties() props.load(new FileInputStream(file("signing.properties"))) Properties serverProps = new Properties() def propFile = file('server_url.properties') def testApiUrl, proApiUrl if (propFile.canRead()) { serverProps.load(new FileInputStream(propFile)) if (serverProps != null) { testApiUrl = serverProps['testApiUrl'] proApiUrl = serverProps['proApiUrl'] } } android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "com.webrain.dailypay" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled true versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" flavorDimensions "versionCode" } productFlavors { dppro { applicationId "com.webrain.dailypay" buildConfigField('String', 'baseApiUrl', proApiUrl) } dptest { applicationId "com.webrain.dailypay.test" buildConfigField('String', 'baseApiUrl', testApiUrl) } } signingConfigs { debug { keyAlias props['KEY_ALIAS'] keyPassword props['KEY_PASSWORD'] storeFile file(props['KEYSTORE_FILE']) storePassword props['KEYSTORE_PASSWORD'] } release { keyAlias props['KEY_ALIAS'] keyPassword props['KEY_PASSWORD'] storeFile file(props['KEYSTORE_FILE']) storePassword props['KEYSTORE_PASSWORD'] } } //自动生成指定名称的release发布版的 apk文件 android.applicationVariants.all { variant -> variant.outputs.all { output -> outputFileName = "DailyPay_${variant.productFlavors[0].name}_${buildType.getName()}_${defaultConfig.versionName}.apk" } } buildTypes { release { //混淆 minifyEnabled true //Zipalign优化 zipAlignEnabled true // 移除无用的resource文件 shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } debug { signingConfig signingConfigs.release } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation project(':baselibrary') implementation 'com.jakewharton:butterknife:8.0.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1' }