第一步:配置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}" />
第三步:将打包文件放如下位置
第四步:打开cmd
到指定项目路径下      gradle build
然后等待数秒后,即可打包成功,成功后在outputs里面找,文件名不带unsign即为打包成功了!
注:如果gradle无法执行,则手动配置gradle的环境变量

更多相关文章

  1. android 常用的代码
  2. 使用FragmentTabHost时,tabwidget被frament覆盖。
  3. Android(安卓)WebView加载本地Html文件
  4. 系统总结归纳一下android
  5. app在android studio的构建过程
  6. android的文件操作
  7. 分享几点Android(安卓)开发中的小技巧吧。不知道算不算?
  8. 浅谈android中的反编译
  9. NPM 和webpack 的基础使用

随机推荐

  1. Android SDK Manager更新报错——Downloa
  2. android开发之权限问题整理
  3. Android高手进阶教程(九)之----Android H
  4. Android 虚拟摇杆,多种模式回调,返回距离级
  5. Android TV蓝牙模块
  6. Android 服务端开发之开发环境配置
  7. Android 实现气泡布局/弹窗,可控制气泡尖
  8. SurfaceFlinger学习之路(一)View的绘制流程
  9. Android快速滚动
  10. androidmanifest.xml高级属性解析