android-studio打包APK相关问题
来源:互联网 发布:手机数据报告 艾瑞 编辑:程序博客网 时间:2024/06/06 20:38
android-studio打包APK相关问题
一、打包流程
1 先签名
Build->General signed APK
点击 create new
输入各种信息 最好把数据保存下来
具体图解流程可以参考:http://blog.csdn.net/woaichimahua/article/details/54427528
讲解几种参数:
-keystore key的存放位置
-keystore的password
-Alias keystore的别名
-key的password
设置好了会创建一个.jks文件在你刚才的path中
然后 输入密码 next
选择 debug (测试)或者 release(发行) 版本
这时会有两个 选择 V1 和V2 两种方式
具体区别见:
http://blog.csdn.net/abc6368765/article/details/69948926
Finish 就OK了
若是通过 Build-> Build apks 这种方式的,是生成的debug(测试版的)在 app\build\outputs\apk\debug 文件夹
他的大小会比 release 的大一些
常见问题:
可以运行 但是不能打包
出现这个问题
一 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
}