当前位置:首页 > 移动开发 > Android Exception: Build failed,unaligned.apks 拒绝访问

Android Exception: Build failed,unaligned.apks 拒绝访问

6个月前 (05-27)70

Question

Android Studio中,Build时报错,Execution failed for task ‘:app:packageDebug’,详见如下:

:app:mergeDebugJniLibFolders
:app:transformNative_libsWithMergeJniLibsForDebug
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug
:app:validateDebugSigning
:app:packageDebug FAILED
Error:Execution failed for task ':app:packageDebug'.
> Failed to create 'D:\...\app\build\outputs\apk\app-debug-unaligned.apks': 拒绝访问。
Information:BUILD FAILED
Information:Total time: 24.975 secs
Information:1 error

发生报错后,若直接去该目录下删除文件,发现无法删除,即便是用管理员权限也无法删除apks文件。

Solution

重启Windows操作系统。重启后,再次Build后成功。
Android Exception: Build failed,unaligned.apks 拒绝访问 _ Java侠

另外,据说使用电脑管家等防护软件的文件粉碎功能,对apk文件夹进行粉碎,然后重新编译也同样有效。

Extension

What is an aligned apk

Aligned APKs are optimized for RAM usage so they will consume less RAM in the devices.

Zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files.....
The benefit is a reduction in the amount of RAM consumed when running the application.

Why unaligned?

通过Gradle构建后,在app/build/apk文件夹下会先生成app-debug-unaligned.apks,然后再从unaligned APK变为aligned,并生成aligned APK。
The unaligned(signed) APK is needed because the signing an aligned apk will undo the alignment.
app-debug-unaligned.apk = Unaligned Signed APK
app-debug.apk = Aligned Signed APK (RAM optimized using zipalign)

APP的构建过程

Android Exception: Build failed,unaligned.apks 拒绝访问 _ Java侠
官方文档解释:

Caution: zipalign must only be performed after the .apk file has been signed with your private key. 
If you perform zipalign before signing, then the signing procedure will undo the alignment.

作者:Pierre_
来源链接:https://blog.csdn.net/pierre_/article/details/51132179

“Android Exception: Build failed,unaligned.apks 拒绝访问” 的相关文章

UncaughtHandler: TinkerUncaughtHandler catch exception:java.lang.IllegalStateException: Two differen

UncaughtHandler: TinkerUncaughtHandler catch exception:java.lang.IllegalStateException: Two differen

         错误日志: 2020-03-02 17:58:14.070 26918-26918/co...

防火墙firewalld报错:ERROR: Exception DBusException: org.freedesktop.DBus.Error.AccessDenied:...

ERROR: Exception DBusException: org.freedesktop.DBus.Error.AccessDenied: Connection ":1.1985"...

Error creating bean with name 'itemCatController'

Error creating bean with name 'itemCatController'

Error creating bean with name 'itemCatController': Injection of autowired dependencies failed...

Android 混淆问题排查

Android 混淆问题排查

问题 近期在开发过程中,突然出现混淆后程序出现运行时异常,编译是正常的,不混淆也是正常的, 错误信息如下提示 12-07 14:10:2...

svnkit 异常:Exception in thread "main" org.tmatesoft.svn.core.SVNException: svn: E200030: SQLite error

https://stackoverflow.com/questions/16063105/org-tmatesoft-sqljet-core-sqljetexception-busy-e...

Error creating bean with name 'sqlSessionFactory' defined in class path resource 报错解决

Error creating bean with name 'sqlSessionFactory' defined in class path resource 报错解决

报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name...

Android 报错 : FATAL EXCEPTION:main 解决方法

Android 报错 : FATAL EXCEPTION:main 解决方法

今天安卓开发课上碰到的新问题。 前景提示:老师让我们自己试一下那个两个页面跳转的效果,于是我就开始写了,然后报错 解决方法:逐一排查...

spring springmvc 注解@service 运行时提示找不到这个service的问题

今天测试spring、springmvc、mybatis,分层为dao、service、serviceimpl、controller,在运行的时候提示 1 org.apa...

Springboot Error creating bean with name xxx defined in file问题

Springboot Error creating bean with name xxx defined in file问题

  从网上尝试了很多内容也于事无补 最后发现其实什么问题也没有 就是在 application.properties配置中的某一行多加了一个空格 哎  ...