Jenkins Android gradle只能打包app-release-unsigned.apk

愿君学长松,慎勿作桃李。这篇文章主要讲述Jenkins Android gradle只能打包app-release-unsigned.apk相关的知识,希望能为你提供帮助。
最近在通过jenkins自动打包安卓apk,但是测试打包的时候发现只能生成app-release-unsigned.apk,这个发到安卓手机因为缺少证书不能安装。解决办法是
1.在app/build.gradle文件中增加signingConfigs字段

apply plugin: ‘com.android.application‘android { compileSdkVersion 21 buildToolsVersion "21.1.0" defaultConfig { applicationId "com.test.example" minSdkVersion 14 targetSdkVersion 21 versionCode 1 versionName "1.0" }signingConfigs { debug { File strFile = new File("../../Keystore/Debug/debug.jks") storeFile file(strFile) storePassword "storeDebug1234567890" keyAlias "debugkey" keyPassword "aliasDebug1234567890" //println strFile.absolutePath; } release { File strFile = new File("../../Keystore/Release/release.jks") storeFile file(strFile) storePassword "storeRelease1234567890" keyPassword "keyRelease1234567890" keyAlias "releasekey" // println strFile.absolutePath; } }buildTypes { release { signingConfigsigningConfigs.release#缺少这段,或者buildtypes在signingconfigs签名 runProguard false proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘ } } }

ps:注意这段的证书路径以及密码根据自己的实际情况进行修改
【Jenkins Android gradle只能打包app-release-unsigned.apk】我们这里就时配置了证书,但是发现还是不能打包release,其实是缺少了signingConfigsigningConfigs.release
重新打包就可以正常生成app-release.apk了。

    推荐阅读