Set-up RenderScript in Android Studio

纵然是瞬间 提交于 2019-12-01 01:50:17
  1. Open Android Studio.
  2. Select "File/New/New Project..."
  3. Press Next
  4. Select "Phone and Tablet" and Minimum SDK: 4.4.
  5. Press Next.
  6. Select "Blank Activity".
  7. Press Next.
  8. Press Finish.
  9. Right-click at the top of hierarchy tree on the left ("app").
  10. Select "New/Folder/RenderScript folder".
  11. Press Finish.
  12. Copy a working renderscript file to newly created "rs" folder.
  13. Double-click on "Gradle Scripts/build.gradle (Module: app).
  14. Insert

    renderscriptTargetApi 18
    renderscriptSupportModeEnabled true
    

at the end of defaultConfig section.

  1. Press Ctrl-F9 to build your project.

There was a bug related to renderscriptTargetApi 21+. This has now been fixed in gradle-plugin 2.1.0 and Build-Tools 23.0.3. Use the code below:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    ...
}

The documentation for IDE setup has also been corrected: http://developer.android.com/guide/topics/renderscript/compute.html#ide-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!