• 世界未解之谜之----------Android Gradle


    今天运行项目,运行的debug出来的包竟然是命名过的,但是我的buildTypes里面的debug 并没有执行重命名操作。很奇怪,我的猜测是: 执行buildTypes的时候,虽然是assermdebug,但是确实走了release里面的东西

    求大神指点:

    build.gradle:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
        useLibrary 'org.apache.http.legacy'
        defaultConfig {
            applicationId "com.aaa.ccc"
            minSdkVersion 14
            targetSdkVersion 23
            multiDexEnabled true
    
            buildConfigField("String", "ChannelId", '"116118"')         //渠道号
        }
        buildTypes {
            debug {
                buildConfigField "boolean", "LOG_DEBUG", "true"          //log 日志
                buildConfigField "String", "URL_CONFIG", ""huidu""  // url 配置:official,huidu,fangzhen
                minifyEnabled false
                zipAlignEnabled false
                debuggable true
                shrinkResources false
            }
            release {
                minifyEnabled true
                proguardFiles 'proguard-project.txt'
                debuggable false
                buildConfigField "boolean", "LOG_DEBUG", "false"
                buildConfigField "String", "URL_CONFIG", ""official""
    
                def versionN = getTodayReleaseVersion()
                applicationVariants.all { variant ->
                    variant.outputs.each { output ->
                        def outputFile = output.outputFile
                        if (outputFile != null && outputFile.name.endsWith('.apk')) {
                            def fileName = "baiduapp_v${getVersionName()}_${releaseDay()}_build${versionN}.apk"
                            output.outputFile = new File(outputFile.parent,fileName)
                        }
                    }
                }
            }
        }
        productFlavors {
        }
    
        lintOptions{
            abortOnError false
        }
        sourceSets{
            main {
                jniLibs.srcDirs = ['jniLibs']
            }
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
    }
    
    dependencies {
        compile project(':plug')
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.android.support:support-v4:23.1.1'
    }
    def releaseDay(){
        return new Date().format("yyyyMMdd",TimeZone.getTimeZone("UTC"))
    }
    
    def getTodayReleaseVersion(){
        def runTasks = gradle.startParameter.taskNames;
        def versionPropsFile = file('buildver.properties')
        def today = releaseDay()
        if(versionPropsFile.canRead()){
            def versionId = 1
            def Properties versionProps = new Properties()
            versionProps.load(new FileInputStream(versionPropsFile))
            def releaseDay = versionProps.get("RELEASE_DAY")
            if(releaseDay.equals(today)) {
                versionId = versionProps.get('VERSION_NAME').toInteger()
                println("-------------"+runTasks);
                def isRelase = false
                runTasks.each { task ->
                    if(task.contains("assembleRelease")){
                        isRelase = true
                    }
                }
                if(isRelase){
                    versionId++
                }
            }else{
                versionProps["RELEASE_DAY"] = today;
            }
    
            versionProps['VERSION_NAME'] = versionId.toString()
            versionProps.store(versionPropsFile.newWriter(),null)
            return versionId.toString();
        }else{
            versionPropsFile.createNewFile();
            def Properties versionProps = new Properties();
            versionProps["RELEASE_DAY"] = releaseDay;
            versionProps['VERSION_NAME'] = versionId.toString()
            versionProps.store(new FileOutputStream(versionPropsFile),null)
        }
        return "1";
    }
    
    def getVersionName(){
        def fileManifest = file("src/main/AndroidManifest.xml")
        def androidManifest = new XmlSlurper().parse(fileManifest)
        return androidManifest.@'android:versionName'
    }
  • 相关阅读:
    django分组group、user、permission
    django权限验证装饰器
    django用户和权限管理
    Selenium+python --如何定位表格中的某一个内容
    Selenium+python --定位下拉列表框并选取内容
    Selenium2+python--iframe
    Selenium3+python3--如何定位鼠标悬停才显示的元素
    Selenium3+python3--定位到元素后如何操作元素
    Selenium+python --如何定位一组元素
    补充前几天测试用到的Linux命令
  • 原文地址:https://www.cnblogs.com/caoxinyu/p/6647729.html
Copyright © 2020-2023  润新知