Browse Source

gradle修改配置

liuyuqi-dellpc 3 years ago
parent
commit
2694cf1165
4 changed files with 37 additions and 6 deletions
  1. 1 0
      .gitignore
  2. 18 6
      app/build.gradle
  3. 2 0
      build.gradle
  4. 16 0
      config.bak.gradle

+ 1 - 0
.gitignore

@@ -13,3 +13,4 @@
 .externalNativeBuild
 .cxx
 /.idea/
+/config.gradle

+ 18 - 6
app/build.gradle

@@ -1,14 +1,25 @@
 apply plugin: 'com.android.application'
 
+def build = rootProject.ext.build
+def sign = rootProject.ext.sign
+
 android {
-    compileSdkVersion 29
+    signingConfigs {
+        release {
+            storeFile file(sign.storeFile)
+            keyAlias sign.keyAlias
+            keyPassword sign.keyPassword
+            storePassword sign.storePassword
+        }
+    }
+    compileSdkVersion build.compileSdkVersion
 
     defaultConfig {
-        applicationId "me.yoqi.android.netauth"
-        minSdkVersion 15
-        targetSdkVersion 29
-        versionCode 1
-        versionName "1.0"
+        applicationId build.applicationId
+        minSdkVersion build.minSdkVersion
+        targetSdkVersion build.targetSdkVersion
+        versionCode build.versionCode
+        versionName build.versionName
 
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }
@@ -17,6 +28,7 @@ android {
         release {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+            signingConfig signingConfigs.release
         }
         debug{
             minifyEnabled false

+ 2 - 0
build.gradle

@@ -1,4 +1,6 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply from:'config.gradle'
+
 buildscript {
     repositories {
         google()

+ 16 - 0
config.bak.gradle

@@ -0,0 +1,16 @@
+ext {
+    build = [
+            applicationId   : "me.yoqi.android.netauth",
+            minSdkVersion   : 21,
+            targetSdkVersion: 29,
+            compileSdkVersion:29,
+            versionCode     : 1,
+            versionName     : "1.0.0",
+    ]
+    sign = [
+            keyAlias     : "签名别名",
+            keyPassword  : "签名密码",
+            storeFile    : "签名文件路径",
+            storePassword: "签名文件密码",
+    ]
+}