gpt4 book ai didi

android - RenderScript:不在 aar 中提供 .so

转载 作者:行者123 更新时间:2023-11-29 17:09:16 24 4
gpt4 key购买 nike

我目前正在构建一个 SDK,并向 SDK 的用户提供一个 .aar 存档。

我的 SDK 中有一个可选功能,基本上可以模糊图像。但是,此功能需要使用 renderScript,由于共享库的存在,这会使 .aar 存档更大。

./jni/armeabi-v7a:
total 3752
rw-rr- 1 cylix wheel 1,1M 29 nov 16:16 libblasV8.so
rw-rr- 1 cylix wheel 746K 29 nov 16:16 libRSSupport.so
rw-rr- 1 cylix wheel 46K 29 nov 16:16 librsjni.so
./jni/mips:
total 5224
rw-rr- 1 cylix wheel 1,5M 29 nov 16:16 libblasV8.so
rw-rr- 1 cylix wheel 1,0M 29 nov 16:16 libRSSupport.so
rw-rr- 1 cylix wheel 70K 29 nov 16:16 librsjni.so
./jni/x86:
total 5344
rw-rr- 1 cylix wheel 1,6M 29 nov 16:16 libblasV8.so
rw-rr- 1 cylix wheel 958K 29 nov 16:16 libRSSupport.so
rw-rr- 1 cylix wheel 54K 29 nov 16:16 librsjni.so
./jni/arm64-v8a:
total 1808
rw-rr- 1 cylix wheel 843K 29 nov 16:16 libRSSupport.so
rw-rr- 1 cylix wheel 60K 29 nov 16:16 librsjni.so

但我注意到,如果我删除库并且不在 .aar 中提供它们,库的客户端仍然可以在其端启用 renderScript 并毫无问题地访问该功能。

然后,如果 renderScript 可用,我只需要检查我的代码:

    try {
Class.forName("android.support.v8.renderscript.RenderScript");
} catch (ClassNotFoundException e) {
//! renderScript not available
}

但这是我的问题。我仍然需要放入我的 gradle 文件:

renderscriptTargetApi 23
renderscriptSupportModeEnabled true

否则项目无法编译。但这会导致自动包含上面列出的 .so 文件...

有什么方法可以解决这个问题:能够编译 renderScript 功能但过滤 .so 文件,使它们不包含在 .aar 存档中?

最佳答案

我相信有更好的解决方案。但这里容易实现的目标是使用 com.android.tools.build:gradle:2.2.0 或更高版本。

dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
// ...
}

gradle 插件 2.2.0+ 不会 bundle libblasV8.so,除非您指定 renderscriptSupportModeBlasEnabled true。这样你的 AAR 文件可能会减少 50% 的权重。

关于android - RenderScript:不在 aar 中提供 .so,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40886407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com