build.gradle 文件

来源:互联网 发布:ubuntu 16.04必装软件 编辑:程序博客网 时间:2024/06/06 11:44
1、build.gradle文件
读出AndroidManifest.xml 里的版本 和版本号  修改输出文件名




2、在gradle文件里设置不同的  host 环境。使不同的
build.gradle文件

buildConfigField "String", "URL", "\"http://vms.xxx.com\""            


buildTypes {    debug_ {        buildConfigField "String", "URL", "\"http://xx.xx.xx.com\""    }
}


java文件:
    public static String mCurrentApi= BuildConfig.URL; 

   public static String getHost {        if (DEBUG) {            return "your qa host";        }        return "your production host";    }

3、多渠道打包
manifest文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.demo.test1"
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:versionCode="34"
          android:versionName="v34.1.1">


    <meta-data
        android:name="UMENG_CHANNEL"
        android:value="${UMENG_CHANNEL_VALUE}"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>


                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>


</manifest>






0 0