AS打包主要分两种
一、 没有“.jks”文件的打包
首先 我们选择Build -> Generate Signed APK
然后
这时候,因为我们现在还没有秘钥文件,所以我们选择create new一个新的秘钥文件
这时候可以选择是否记住密码,我一般是勾选上的,然后点击next
点击finish,稍等片刻,在APP目录下或者你所设置的apk存放目录下
完成
二、 有“.jks”文件的打包
同样,首先 我们选择Build -> Generate Signed APK
然后
这时,我们选择choose existing,选择一个已有的秘钥文件
点击finish,稍等片刻,在APP目录下或者你所设置的apk存放目录下
完成
常见问题:
可以运行 但是不能打包
出现这个问题
一 Failed to read PNG signature: file does not start with PNG signature
第一种方案: invalidate caches
第二种方案: 图片格式有问题 可能是后缀更改了,可能是图片压缩时产生的问题。 重新处理图片再加载
第三种方案:
在module的build中,加入aaptOptions { cruncherEnabled = false }
做完这一步 又出现:Error:Error: Expected resource of type styleable [ResourceType]
根据messages的 complete output in console
加
* What went wrong:
Execution failed for task ‘:app:lintVitalRelease’.
Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
…
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
…
二 Error: Expected resource of type styleable [ResourceType]
将 那个 使用TypedArray 的地方 用@SuppressWarnings(“ResourceType”) 注释掉
三 还是有错误 根据messages的 complete output in console
加
lintOptions {
//在打包Release版本的时候不进行检测
checkReleaseBuilds false
// 有报错也不会停止打包
abortOnError false
}
三、Failed to read key from keystore
1. 可能是别名.keyAlias的错误
输入密码 点击key alias 后面的… 目录
Use an existing key 然后OK 将Alias改一下
2.android.keystore可能不在指定目录下面
四、Cannot recover key
1. 可能是密码错误,key password错误