我正在尝试使我的应用程序与新的PlayStore要求兼容64位。我们确实在应用程序中使用了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 Developer文档指出,使用任何C或C ++代码可能会使您的应用程序不兼容。但是,我找不到专门针对RenderScript的解决方案。
答案 0 :(得分:2)
好的,原来我必须做两件事:
使用更新版本的Renderscript。我将目标定为22,并将renderscriptSupportModeEnabled设置为true。还必须确保我使用的是android.support.v8.renderscript.RenderScript而不是android.Renderscript。
还原AndroidX。这是一个任务!由于某种原因,它不得不将androidX淘汰,因为它拒绝与Renderscript完美配合。例如,它将在Android5上崩溃,并且只是拒绝与64位兼容。
我希望这可以帮助某个人!
O,最后一个提示:您可以使用bundletool测试捆绑软件是否兼容64位。我发现此站点非常有用:https://www.raywenderlich.com/9043-android-app-bundles-getting-started
-它会告诉您是否无法构建64位apk。