使用APK Splits进行发布,但不能使用“调试”构建类型

编程入门 行业动态 更新时间:2024-10-10 10:25:18
本文介绍了使用APK Splits进行发布,但不能使用“调试”构建类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已成功实施 APK拆分,以便为不同的ABI生成不同的APK。然而,为了提高效率(因为我不需要调试中的非armeabi-v7a APK),我想限制调试版本只能生成armeabi-v7a APK。

如何做到这一点?

这:

abi {启用true reset() include'x86', 'armeabi-v7a','mips' universalApk false }

也许有一些方法可以根据Build类型设置 enable ?

解决方案

你可以在@ Geralt_Encore的答案上尝试一个变体,它避免了单独的 gradlew 命令。在我的情况下,我只关心使用APK拆分来减少发布的APK文件大小,我想完全在Android Studio中完成此操作。

splits { abi {启用gradle.startParameter.taskNames.contains(:app:assembleRelease) reset() include'x86','armeabi -v7a','mips' universalApk false } }

如果应用程序模块的名称不是字面上的 app >,则可能需要将:app 。

从我所看到的Build |在Android Studio中生成签名的APK菜单项会使用 assembleRelease Gradle目标生成APK。

请注意,使用构建版本重新生成APK,或者您的版本构建未命名为 release ,您需要更改 assembleRelease 相应的目标,例如 assemblePaidRelease 如果您的构建风格是已付款。

I've successfully implemented APK Splits so that separate APKs are generated for different ABIs.

However, for efficiency (and since I have no need for non-armeabi-v7a APKs in Debug), I would like to limit Debug builds to only generate armeabi-v7a APKs.

How can this be done?

One idea is with this:

abi { enable true reset() include 'x86', 'armeabi-v7a', 'mips' universalApk false }

Maybe there is some way to set enable based on the Build type?

解决方案

You can try a variation on @Geralt_Encore's answer, which avoids the separate gradlew command. In my case, I only cared to use APK splitting to reduce the released APK file size, and I wanted to do this entirely within Android Studio.

splits { abi { enable gradle.startParameter.taskNames.contains(":app:assembleRelease") reset() include 'x86', 'armeabi-v7a', 'mips' universalApk false } }

You may need to replace the :app prefix with the name of your application module if it's not literally named app.

From what I've seen, the Build | Generate Signed APK menu item in Android Studio generates the APK using the assembleRelease Gradle target.

Note that if you're generating an APK using build flavors, or your release build isn't named release, you'll need to change the assembleRelease target accordingly, e.g. assemblePaidRelease if your build flavor is paid.

更多推荐

使用APK Splits进行发布,但不能使用“调试”构建类型

本文发布于:2023-11-05 10:00:40,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但不   类型   APK   Splits

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!