gradle命令行操作笔记

时间:2022-02-09 17:39:56

gradle命令行操作笔记

标签: gradle


  • 环境 path中加入D:\apps\android-studio\gradle\gradle-2.4\bin,因为我要使用本地的gradle
  • 打包

    • 命令

      1. gradle.bat app:assembleRelease#打全部包
      2. gradle.bat app:assembleDevRelease#只打测试包
      3. gradle.bat app:assembleStageRelease
      4. gradle.bat app:assembleProductRelease
    • 生成文件在app\build\outputs\apk

  • 文件app\build.gradle

    android {
    signingConfigs {
    config {
    storeFile file(RELEASE_STORE_FILE)
    storePassword RELEASE_STORE_PASSWORD
    keyAlias RELEASE_KEY_ALIAS
    keyPassword RELEASE_KEY_PASSWORD
    }
    }
    //flavors
    productFlavors {
    dev {
    buildConfigField "String", "API_BASE_URI", '"http://wms.test.yunshanmeicai.com/"'
    resValue "string", "api_name", "test"
    }
    stage {
    buildConfigField "String", "API_BASE_URI", '"http://wms.stage.yunshanmeicai.com/"'
    resValue "string", "api_name", "stage"
    }
    product {
    buildConfigField "String", "API_BASE_URI", '"http://beta.wms.yunshanmeicai.com/"'
    resValue "string", "api_name", "正式"
    }
    }
    }
  • 文件gradle.properties

    systemProp.http.proxyHost=127.0.0.1
    systemProp.http.proxyPort=1080
    systemProp.https.proxyHost=127.0.0.1
    systemProp.https.proxyPort=1080


    RELEASE_STORE_FILE=catuncle.jks
    RELEASE_STORE_PASSWORD=123456
    RELEASE_KEY_ALIAS=catuncle
    RELEASE_KEY_PASSWORD=123456