import java.text.SimpleDateFormatimport java.util.regex.Matcherimport java.util.regex.Patternapply plugin: 'com.android.application'android {    compileSdkVersion 26    defaultConfig {        applicationId "com.excellence.netlink"        minSdkVersion 17        targetSdkVersion 26        versionCode = getSvnVersion()        versionName = "V2.0." + versionCode + ' [' + getDate()+ "]"        println 'versionCode: '+versionCode + '\n' + 'versionName: '+versionName        creatVersionInfo()    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }    applicationVariants.all{ variant->        variant.getPackageApplication().outputDirectory = new File(outputDir())        variant.outputs.all { output->            if (variant.buildType.name.equals('release') || variant.buildType.name.equals('debug')) {                outputFileName= "m3u8Player"+versionName+".apk"            }        }    }}def outputDir(){    return project.buildDir.absolutePath+"/outputs/apk"}def getSvnVersion() {    def proc = ("svnversion -c " + getBuildDir().parent).execute();    proc.waitFor();    def version = proc.in.text;    Pattern p = Pattern.compile("(\\d+\\:)?(\\d+)\\D?");    Matcher m = p.matcher(version);    if (m.find()) {        version = m.group(m.groupCount());    }    try    {        return Integer.parseInt(version);    }    catch (e)    {        println e.getMessage()    }    return 0;}def getDate() {    SimpleDateFormat sdf = new SimpleDateFormat('MMM d yyyy', Locale.US);    return sdf.format(new Date());}def creatVersionInfo() {    try    {        FileOutputStream outStream = new FileOutputStream(getBuildDir().parent + '/assets/verson_config.properties');        Properties properties = new Properties();        properties.put("svn_ver", '' + getSvnVersion());        properties.put("build_time", getDate());        properties.store(outStream, null);        outStream.flush();        outStream.close();    }    catch (e)    {        println e.getMessage()    }}dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])    implementation 'com.jakewharton:butterknife:8.7.0'    annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'    implementation 'com.vise.xiaoyaoyou:viselog:1.1.2'    implementation 'com.orhanobut:hawk:2.0.1'}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android ListView中添加ImageButton按钮
  2. Android(安卓)下的图片选择与裁剪开源库
  3. Android(安卓)布局 之 LinearLayout
  4. android图片压缩的3种方法实例
  5. android api (83) —— InputMethodSessi
  6. Android(安卓)Java执行Shell命令
  7. Android(安卓)屏幕截图并用WindowManager
  8. 基于MQTT实现Android消息推送(Push)(2)
  9. android 有关怎么自己添加系统级服务 jav
  10. Android(安卓)网络(四) Retrofit学习笔记