第一步:配置build


apply plugin: 'com.android.application'android {    compileSdkVersion 21    buildToolsVersion "22.0.1"    packagingOptions {        exclude 'META-INF/NOTICE.txt'        exclude 'META-INF/LICENSE.txt'    }    //签名    signingConfigs {        release {            storeFile file("txfund_keystore.jks")            storePassword "123456"            keyAlias "TXFund"            keyPassword "123456"        }    }    defaultConfig {        applicationId "org.lmw.demo.slidingtab"        minSdkVersion 14        targetSdkVersion 21    }    buildTypes {        release {            // 不显示Log            //buildConfigField "boolean", "LOG_DEBUG", "false"            //minifyEnabled true //混淆            zipAlignEnabled true //内存对齐            shrinkResources true //移除无用的resource文件            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'            signingConfig signingConfigs.release            android.applicationVariants.all { variant ->                def stringsFile = new File(variant.outputs[0].processResources.assetsDir, "abc.txt")                stringsFile.mkdir()            }            applicationVariants.all { variant ->                variant.outputs.each { output ->                    def outputFile = output.outputFile                    if (outputFile != null && outputFile.name.endsWith('.apk')) {                        def fileName = "APK_${releaseTime()}_${variant.productFlavors[0].name}.apk"                        output.outputFile = new File(outputFile.parent, fileName)                    }                }            }        }    }    lintOptions {        checkReleaseBuilds false        abortOnError false        ignoreWarnings true    }    // 渠道列表    productFlavors {        _360 {}        _91 {}        QQ {}        appChina {}        baidu {}        google {}        //.....    }    productFlavors.all { flavor ->        flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]    }}def releaseTime() {    return new Date().format("yyyy-MM-dd HH-mm-ss", TimeZone.getTimeZone("GMT+8"))}dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    compile 'com.android.support:support-v4:22.2.1'    compile files('libs/xutils-library-2.4.7.jar')}
第二步:配置文件加入变量
<!-- 友盟Start --> <meta-data    android:name="UMENG_APPKEY"    android:value="……" /><meta-data    android:name="UMENG_CHANNEL"    android:value="${UMENG_CHANNEL_VALUE}" />
第三步:将打包文件放如下位置
Android Studio批量打包_第1张图片
第四步:打开cmd
到指定项目路径下      gradle build
然后等待数秒后,即可打包成功,成功后在outputs里面找,文件名不带unsign即为打包成功了!
注:如果gradle无法执行,则手动配置gradle的环境变量

更多相关文章

  1. Android WebView加载本地Html文件
  2. Android分享文件到微信和QQ功能的实现(兼容android 7.0以上的共享
  3. Android、pc文件无线双向传输软件
  4. Linux文件的特殊权限位SUID、SGID作用及编程设置/读取
  5. Android8.1以及5.1版本识别sdcard和U盘并创建文件解决办法
  6. 使用ant让Android自动打包的build.xml,自动生成签名的apk文件(支
  7. Android 事件全局监听(二)需要root权限 ,使用getevent监听Android输

随机推荐

  1. Android文档(一)——什么是Android?
  2. Android系列教程之Android项目的目录结构
  3. Android日历功能有GestureDetector手势识
  4. Android通过OpenGl Es渲染NV21格式视频
  5. Android使用TextView实现无下划线超链接
  6. Android数据存储(二) Files
  7. Android(安卓)热补丁实践之路
  8. android开机动画制作与播放原理简介
  9. Android(安卓)Studio (IntelliJ/IDEA)在And
  10. Android之log