zoukankan      html  css  js  c++  java
  • build.gradle 使用tips

    7.查看依赖

    gradlew [你想查看的module]:dependencies >dependencies.txt

    6.buildToolsVersion build tools版本号

      compileSdkVersion android sdk版本

    5.删除无用资源

    android {
        buildTypes {
            release {
                minifyEnabled true
                shrinkResources true
            }
        }
    }

    4.定义资源类型变量(可以在代码中R.string.ResName调用)

    android{
      productFlavors {
            dev {
                resValue "string", "ResName", "ResValueForDebug"
            }
            product {
                resValue "string", "ResName", "ResValueForProduct"
            }
      }
    }

    3.在build.gradle里面定义常量,在AndroidManifest里面使用

    manifestPlaceholders = [app_channel:"google_play"]

    在AndroidManifest里面使用${app_channel}

    2.在gradle.properties定义常量

    在gradle.properties

    VALUE_1="一些自定义的内容"
    VALUE_2="一些自定义的内容"
    VALUE_3="一些自定义的内容"

    在build.gradle引用, 注意,下面的VALUE1就是直接引用, 赋值给COSTOM_FIELD这个字段

    android{    
        defaultConfig {
            buildConfigField 'String', 'CUSTOM_FIELD', VALUE1
        }
    }

    1.自定义BuildConfig字段

    在android模块内添加下面脚本,下面设置之后直接在代码里使用BuildConfig.HOST即可使用

    android{
      productFlavors { dev { buildConfigField
    'String', 'HOST', '"http://api.zzb.com/debug"' } product { buildConfigField 'String', 'HOST', '"http://api.zzb.com/product"' }   }
    }
  • 相关阅读:
    SpringBoot创建定时任务
    SpringBoot 多环境配置
    SpringBoot中使用log4j日志
    SpringBoot项目结构介绍
    SpringBoot快速入门
    Zookeeper Zkclient客户端
    Zookeeper java api
    学习微信小程序及知识占及v-if与v-show差别

    1像素
  • 原文地址:https://www.cnblogs.com/baron89/p/4689470.html
Copyright © 2011-2022 走看看