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 {
            signingConfig  signingConfigs.release   #缺少这段,或者buildtypes在signingconfigs签名
            runProguard false
            proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
        }
    }
}

ps:注意这段的证书路径以及密码根据自己的实际情况进行修改

我们这里就时配置了证书,但是发现还是不能打包release,其实是缺少了signingConfig signingConfigs.release
重新打包就可以正常生成app-release.apk了。

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

上一篇:LG P4149 [IOI2011]Race


下一篇:移动端ios针对input虚拟键盘挡住的问题