[英]Is it possible to use RenderScript on Android SDK 23+
I've been struggling with getting RenderScript to work on my app with a TargetSDKVersion 26 and a minSDKVersion 21 getting an error at Gradle Sync: 我一直在努力使RenderScript在TargetSDKVersion 26和minSDKVersion 21上运行于我的应用程序,但在Gradle Sync出现错误:
Error:Execution failed for task ':app:compileDebugRenderscript'. 错误:任务':app:compileDebugRenderscript'的执行失败。 com.android.ide.common.process.ProcessException: Error while executing process /home/mail929/.android/sdk/build-tools/26.0.2/llvm-rs-cc with arguments {-O 3 -I /home/mail929/.android/sdk/build-tools/26.0.2/renderscript/include/ -I /home/mail929/.android/sdk/build-tools/26.0.2/renderscript/clang-include/ -p /home/mail929/Code/Android/SmartME/app/build/generated/source/rs/debug -o /home/mail929/Code/Android/SmartME/app/build/generated/res/rs/debug/raw -target-api 21 /home/mail929/Code/Android/SmartME/app/src/main/rs/combine.rs} com.android.ide.common.process.ProcessException:执行进程/home/mail929/.android/sdk/build-tools/26.0.2/llvm-rs-cc时出现错误,参数为{-O 3 -I / home / mail929 / .android / sdk / build-tools / 26.0.2 / renderscript / include / -I /home/mail929/.android/sdk/build-tools/26.0.2/renderscript/clang-include/ -p / home / mail929 /代码/ Android / SmartME / app / build / Generated / source / rs / debug -o / home / mail929 / Code / Android / SmartME / app / build / Generated / res / rs / debug / raw -target-api 21 /home/mail929/Code/Android/SmartME/app/src/main/rs/combine.rs}
Eventually I noticed at the bottom of the documentation page : 最终我注意到文档页面的底部:
Graphics Functions and Types 图形功能和类型
The graphics subsystem of RenderScript was removed at API level 23. RenderScript的图形子系统在API级别23被删除。
Does this mean I can't use RenderScript at all? 这是否意味着我根本无法使用RenderScript? If so are there any good alternatives? 如果是这样,有什么好的选择吗?
Here is my complete build.gradle: 这是我完整的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "edu.marquette.mcw.smartme"
minSdkVersion 21
targetSdkVersion 26
versionCode 4
versionName "2rc1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 18
renderscriptSupportModeEnabled false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:cardview-v7:26.0.0'
testCompile 'junit:junit:4.12'
}
No, Renderscript hasn't been completely deprecated, only the graphics functionality which operated on some OpenGL type constructs directly. 不,Renderscript还没有被完全弃用,只是直接在某些OpenGL类型构造上运行的图形功能。 Since it was more or less doing the same thing available in OpenGL, it was dropped and instead you can exchange textures with OpenGL. 由于它或多或少都在执行OpenGL中可用的相同操作,因此已将其删除,而可以与OpenGL交换纹理。
The combination of minSdkVersion
and renderscriptTargetApi
in your build.gradle
will result in the minSdkVersion
being used for the Renderscript target API. 的组合minSdkVersion
和renderscriptTargetApi
在你build.gradle
将导致minSdkVersion
被用于的renderScript目标API。 The way this works can get really odd. 这种工作方式可能真的很奇怪。 Unless you absolutely need something in the android.renderscript
framework package, use the support library version by setting renderscriptSupportModeEnabled
to true
. 除非您绝对需要android.renderscript
框架包中的内容,否则通过将renderscriptSupportModeEnabled
设置为true
来使用支持库版本。 This may also help resolve whatever issue you are seeing. 这也可能有助于解决您遇到的任何问题。 If it doesn't, try to provide more details from the build log. 如果不是,请尝试从构建日志中提供更多详细信息。
Well I actually decided to manually run the command to see what was wrong and recevied the following error: 好吧,我实际上决定手动运行命令以查看出了什么问题,并纠正了以下错误:
error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory 加载共享库时出错:libncurses.so.5:无法打开共享库文件:没有这样的文件或目录
I fixed this by installing ncurses-compat-libs on Fedora and Gradle Sync completes successfully 我通过在Fedora上安装ncurses-compat-libs来解决此问题,并且Gradle Sync成功完成
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.