简体   繁体   English

Android Studio 0.2.2上的renderscript错误

[英]Error with renderscript on android studio 0.2.2

I have been attempting to run the HelloCompute sample given in the sample code package, and I have run into a problem. 我一直在尝试运行示例代码包中给出的HelloCompute示例,但我遇到了一个问题。

I put all the renderscript code in a file called "mono.rs" as below (with my package name of course) 我将所有renderscript代码放在一个名为“mono.rs”的文件中,如下所示(当然我的包名称)

Regardless, whenever I attempt to reference the java class that is supposed to have been reflected from this file, using the statement 无论如何,每当我尝试使用以下语句引用应该从该文件反映的java类时,

private ScriptC_mono mScript;

I get an error which says that android studio "Cannot resolve symbol 'ScriptC_mono'". 我得到一个错误,说安卓工作室“无法解析符号'ScriptC_mono'”。

Is there something wrong with my approach. 我的方法有问题吗? is there some way to make the renderscript file reflect itself. 有什么方法可以使renderscript文件反映自己。 I found something about a renderscript error in a recent bug report but it appeared to have been fixed in 22.0.4. 我在最近的错误报告中发现了有关renderscript错误的信息,但似乎已在22.0.4中修复。

After about three days of struggling with this, I found that the problem was with the project folder structure, when compiling with gradle. 经过大约三天的努力,我发现问题在于项目文件夹结构,在使用gradle进行编译时。 This project shows the correct structure: 该项目显示了正确的结构:

https://android.googlesource.com/platform/tools/build/+/11086782041b302109e8349e13b8f9d5e305341d/tests/renderscript/ https://android.googlesource.com/platform/tools/build/+/11086782041b302109e8349e13b8f9d5e305341d/tests/renderscript/

In short, the .rs files should not be together with the java files, but in a separate folder called 'rs' alongside java and res, with the same inside structure, such as "...\\HelloRSProject\\HelloRS\\src\\main\\rs\\com\\example\\hellors\\mono.rs". 简而言之,.rs文件不应与Java文件一起使用,而应与Java和res一起放在单独的名为“ rs”的文件夹中,并具有相同的内部结构,例如“ ... \\ HelloRSProject \\ HelloRS \\ src \\ main \\ RS \\ COM \\例子\\ hellors \\ mono.rs”。 Also, be sure to add renderscriptTargetApi to the build.gradle file, like so: 另外,请务必将renderscriptTargetApi添加到build.gradle文件中,如下所示:

android {
    compileSdkVersion 17
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 16
        renderscriptTargetApi = 16
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM