androidstudio ftp发布apk

来源:互联网 发布:像果网络购物平台 编辑:程序博客网 时间:2024/06/05 05:19

androidstudio 发布apk

apply plugin: 'com.android.application'android {    signingConfigs {        release {            keyAlias 'TrafficLawEnforcementAPPSign'            keyPassword 'TrafficLawEnforcementAPP0816'            storeFile file('../keys/TrafficLawEnforcementAPP-release-key.keystore')            storePassword 'TrafficLawEnforcementAPP0816'        }    }    compileSdkVersion 25    buildToolsVersion "26.0.1"    packagingOptions {        exclude 'META-INF/DEPENDENCIES.txt'        exclude 'META-INF/LICENSE.txt'        exclude 'META-INF/NOTICE.txt'        exclude 'META-INF/NOTICE'        exclude 'META-INF/LICENSE'        exclude 'META-INF/DEPENDENCIES'        exclude 'META-INF/notice.txt'        exclude 'META-INF/license.txt'        exclude 'META-INF/dependencies.txt'        exclude 'META-INF/LGPL2.1'    }    defaultConfig {        applicationId "com.haiwei.a45027.myapplication"        minSdkVersion 21        targetSdkVersion 25        versionCode 1        versionName "0.0.1"        multiDexEnabled true        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }    buildTypes {        debug {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'            buildConfigField("String", "HTTP_BASE", '"http://192.168.0.4:8020"')        }        release {            minifyEnabled false//            shrinkResources true //是否清理无用资源,依赖于minifyEnabled            zipAlignEnabled true //是否启用zipAlign压缩            signingConfig signingConfigs.release            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'            buildConfigField("String", "HTTP_BASE", '"http://117.158.15.170:8020"')        }    }    dexOptions {        javaMaxHeapSize "4g"    }    android.applicationVariants.all { variant ->        variant.outputs.each { output ->            def outputFile = output.outputFile            if (outputFile != null && outputFile.name.endsWith('.apk')) {                //这里修改apk文件名                def fileName = "TrafficLawEnforcementAPP-" + defaultConfig.versionCode + "-" + defaultConfig.versionName + "-release.apk"                output.outputFile = new File(outputFile.parent, fileName)            }        }    }}configurations {    ftpAntTask}repositories {    mavenCentral()    maven { url "https://jitpack.io" }}dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {        exclude group: 'com.android.support', module: 'support-annotations'    })    //    compile 'com.squareup.okhttp3:okhttp:3.2.0'    compile('com.zhousf.lib:okhttp3:2.8.9') {        exclude(module: 'support-annotations')    }    compile('com.thoughtworks.xstream:xstream:1.4.9') {        exclude group: 'xmlpull', module: 'xmlpull'    }    ftpAntTask("org.apache.ant:ant-commons-net:1.8.4") {        module("commons-net:commons-net:1.4.1") {            dependencies "oro:oro:2.0.8:jar"        }    }    compile 'com.github.open-android:LoopViewPager:2.0.0'    compile 'com.chanven.lib:cptr:1.1.0'    compile 'com.android.support:appcompat-v7:25.3.1'    compile 'com.android.support.constraint:constraint-layout:1.0.2'    compile 'com.android.support:design:25.3.1'    compile 'com.alibaba:fastjson:1.2.14'    compile 'com.yanzhenjie:album:2.0.0-alpha'    compile 'cn.finalteam:galleryfinal:1.4.6'    compile 'me.codeboy.android:align-text-view:2.3.0'    compile 'com.bm.photoview:library:1.4.1'    compile project(':libEasyPR')    testCompile 'junit:junit:4.12'}task deployStaging << {    ant {        taskdef(name: 'ftp',                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',                classpath: configurations.ftpAntTask.asPath)        ftp(server: "192.168.0.4", userid: "hiwei-app", password: "123456", remoteDir: "TrafficLawEnforcementAPP") {            fileset(dir: "build/outputs/apk")                    {                        include(name: "TrafficLawEnforcementAPP-" + android.defaultConfig.versionCode + "-" + android.defaultConfig.versionName + "-release.apk")                    }        }    }    new File('app/updateinfo.json').withWriter('utf-8') {        writer -> writer.writeLine '{"apkInfo":{"apkName":"TrafficLawEnforcementAPP-' + android.defaultConfig.versionCode + "-" + android.defaultConfig.versionName + "-release.apk" + '","versionName": "' + android.defaultConfig.versionName + '","versionCode":' + android.defaultConfig.versionCode + '}}'    }    ant {        taskdef(name: 'ftp',                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',                classpath: configurations.ftpAntTask.asPath)        ftp(server: "192.168.0.4", userid: "hiwei-app", password: "123456", remoteDir: "TrafficLawEnforcementAPP") {            fileset(dir: "")                    {                        include(name: "updateinfo.json")                    }        }    }}task deployProduction << {    ant {        taskdef(name: 'ftp',                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',                classpath: configurations.ftpAntTask.asPath)        ftp(server: "47.92.82.253", userid: "appftp", password: "HIWEI@713", remoteDir: "TrafficLawEnforcementAPP") {            fileset(dir: "build/outputs/apk")                    {                        include(name: "TrafficLawEnforcementAPP-" + android.defaultConfig.versionCode + "-" + android.defaultConfig.versionName + "-release.apk")                    }        }    }    new File('app/updateinfo.json').withWriter('utf-8') {        writer -> writer.writeLine '{"apkInfo":{"apkName":"TrafficLawEnforcementAPP-' + android.defaultConfig.versionCode + "-" + android.defaultConfig.versionName + "-release.apk" + '","versionName": "' + android.defaultConfig.versionName + '","versionCode":' + android.defaultConfig.versionCode + '}}'    }    ant {        taskdef(name: 'ftp',                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',                classpath: configurations.ftpAntTask.asPath)        ftp(server: "192.168.0.4", userid: "hiwei-app", password: "123456", remoteDir: "TrafficLawEnforcementAPP") {            fileset(dir: "")                    {                        include(name: "updateinfo.json")                    }        }    }}
原创粉丝点击