【问题标题】:Is it possible to use RenderScript on Android SDK 23+是否可以在 Android SDK 23+ 上使用 RenderScript
【发布时间】:2018-03-07 18:33:08
【问题描述】:

我一直在努力让 RenderScript 在我的应用上运行,TargetSDKVersion 26 和 minSDKVersion 21 在 Gradle Sync 中出现错误:

错误:任务 ':app:compileDebugRenderscript' 执行失败。 com.android.ide.common.process.ProcessException:使用参数 {-O 3 -I /home/ 执行进程 /home/mail929/.android/sdk/build-tools/26.0.2/llvm-rs-cc 时出错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}

最后我注意到documentation page的底部:

图形函数和类型

RenderScript 的图形子系统在 API 级别 23 中被移除。

这是否意味着我根本无法使用 RenderScript?如果有,有什么好的选择吗?

这是我完整的 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'
}

【问题讨论】:

    标签: android renderscript


    【解决方案1】:

    不,Renderscript 并没有被完全弃用,只有直接在某些 OpenGL 类型构造上运行的图形功能。由于它在 OpenGL 中或多或少地做同样的事情,所以它被删除了,你可以用 OpenGL 交换纹理。

    build.gradle 中的minSdkVersionrenderscriptTargetApi 的组合将导致minSdkVersion 用于Renderscript 目标API。这种工作方式可能会变得非常奇怪。除非您绝对需要 android.renderscript 框架包中的某些内容,否则通过将 renderscriptSupportModeEnabled 设置为 true 来使用支持库版本。这也可能有助于解决您遇到的任何问题。如果没有,请尝试从构建日志中提供更多详细信息。

    【讨论】:

      【解决方案2】:

      好吧,我实际上决定手动运行命令以查看错误并收到以下错误:

      加载共享库时出错:libncurses.so.5:无法打开共享对象文件:没有这样的文件或目录

      我通过在 Fedora 上安装 ncurses-compat-libs 解决了这个问题,并且 Gradle Sync 成功完成

      【讨论】:

        猜你喜欢
        • 2015-12-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-01
        相关资源
        最近更新 更多