更新:好的,所以我对此进行了更深入的研究。设法使用 bundletool 来尝试和测试不同的 apk,发现了这个:
“App Bundle 包含 32 位 RenderScript 位码文件 (.bc),它会禁用 Android 中的 64 位支持。”
有谁知道我该如何解决这个问题?渲染脚本构成了项目的一个非常重要的部分。
我正在尝试让我的应用程序 64 位兼容新的 PlayStore 要求。我们确实在应用程序中使用了 RenderScript,所以我想知道这是否会导致问题?而且,如何解决这些问题?渲染脚本是一个非常小的脚本,它只根据输入输出带有绿色或红色部分的位图。
#pragma version(1)
#pragma rs java_package_name(za.co.overtake)
int*reds;
int*greens;
int*blues;
int imgWidth;
uchar4 RS_KERNEL root(uchar4 in, uint32_t x, uint32_t y) {
bool colourme = false;
for(int col = 0; col < imgWidth; col++){
const int red = reds[col];
const int green = greens[col];
const int blue = blues[col];
if (in.r == red && in.g == green && in.b == blue){
colourme = true;
}
}
if (colourme) {
// Cannot increase red amount much as it will cause issues when capturing the image in 565
// format.
in.r = 100;
in.g = 10;
in.b = 10;
in.a = 100;
} else if (in.a > 200) {
in.r = 21;
in.g = 63;
in.b = 81;
in.a = 100;
} else {
in.r = 0;
in.g = 0;
in.b = 0;
in.a = 0;
}
return in;
}
我们在java中这样调用这个脚本:
final RenderScript rs = RenderScript.create(this);
final Allocation input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT | Allocation.USAGE_SHARED);
final Allocation output = Allocation.createTyped(rs, input.getType());
final ScriptC_singlesource script = new ScriptC_singlesource(rs);
Allocation red = Allocation.createSized(rs, Element.I32(rs), reds.length);
red.copyFrom(reds);
script.bind_reds(red);
Allocation green = Allocation.createSized(rs, Element.I32(rs), greens.length);
green.copyFrom(greens);
script.bind_greens(green);
Allocation blue = Allocation.createSized(rs, Element.I32(rs), blues.length);
blue.copyFrom(blues);
script.bind_blues(blue);
script.set_imgWidth(noOfColours);
script.forEach_root(input, output);
output.copyTo(bitmap);
RenderScript blur = RenderScript.create(this);
ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(blur, Element.U8_4(blur));
Allocation tmpIn = Allocation.createFromBitmap(blur, bitmap);
Allocation tmpOut = Allocation.createFromBitmap(blur, bitmap);
theIntrinsic.setRadius(4.0f);
theIntrinsic.setInput(tmpIn);
theIntrinsic.forEach(tmpOut);
tmpOut.copyTo(bitmap);
Android 开发者文档指出,使用任何 C 或 C++ 代码都可能使您的应用程序不兼容。但是,我找不到专门针对 RenderScript 的解决方案。