如何防止或删除库字符串资源以我的apk结尾?

问题描述 投票:0回答:1

[我使用一个外部库声明了一些字符串,这些字符串最终出现在我的apk中,我需要删除它们或首先防止它们到达那里。

我一直在寻找解决方案,但我只找到如何删除未使用的资源,但这不能解决。

android apk android-resources android-library android-build
1个回答
-1
投票

如果知道您的库和应用程序的软件包名称,则可以使用Resources.getIdentifier。>>

您可以为应用程序做:

resources.getIdentifier("icon", "drawable", "com.company.app");

您可以为应用程序做:

resources.getIdentifier("icon", "drawable", "com.library.package");

您将获得一个Int资源,然后可以使用它

val resourceID = resources.getIdentifier("icon", "drawable", "com.library.package");
icon.setImageDrawable(resources.getDrawable(resourceID, theme))
© www.soinside.com 2019 - 2024. All rights reserved.