我将Android studio从 Preview 2 更新为 Preview 3 ,现在当我尝试生成发行版APK时出现此错误:

Error:A problem was found with the configuration of task ':app:packageProdRelease'.
> File '/Users/jay/repositories/test/app/build/intermediatesError:A problem was found with the configuration of task ':app:packageProdRelease'.
> File '/Users/jay/repositories/test/app/build/intermediates/res/resources-prod-release-stripped.ap_' specified for property 'resourceFile' does not exist.

我已经读到它可能与即时运行功能有关,因此我禁用了它,并且仍然是相同的错误。然后,我尝试将shrinkResources属性设置为false,然后它开始工作。但是,当我尝试在 Google开发者控制台中上传apk时,它说我的apk不是 Zipaligned ...

无论您在哪里,Google Developper,请帮帮我! :O

最佳答案

如果我使用gradle 2.2.0-alpha3,则会对我产生此问题。我找到了解决此问题的方法。您可以通过在gradle中禁用rinkreResources和zipalign,然后使用命令行运行zipalign来解决此问题。

build.gradle:

shrinkResources false
zipAlignEnabled false

手动运行zipalign命令:
<your-android-sdk-path>/sdk/build-tools/23.0.3$
./zipalign -v 4 <your-input>.apk <your-output>.apk

编辑:

我只是尝试使用较旧版本的gradle 2.1.0,它可以正常工作而不会出现此问题。 gradt 2.2.0-alpha3中的zipalign问题也在this SO thread中提到。

10-07 22:32