I've just started renderscript in Android Studio. When I make a .rs file, both ScriptC_DS class and a .bc file is not being generated. I've read that it's supposed to be auto-generated once the .rs file is saved, so I'm not sure what's going wrong.
DS.rs
#pragma version(1)
#pragma rs java_package_name(com.example.DSing)
void root(){
}
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.DSing"
minSdkVersion 16
targetSdkVersion 20
versionCode 1
versionName "1.0"
renderscriptTargetApi 18
renderscriptSupportMode true
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
The MainActivity class currently has nothing (aside from auto generated defaults), but when I try to create private ScriptC_DS inside, I get a message saying "Cannot resolve symbol ScriptC_DS." MainActivity
package com.example.DSing
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v8.renderscript.*;
public class Main extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
private ScriptC_DS test;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Question: What am I doing wrong?
The problem you are having is because the default project layout in Android Studio is different than that of Eclipse. You could see this from the app/src/main/java
layout. The poorly documented piece is that RenderScript (and AIDL) now get their own directories in the source set rather than getting thrown into the Java source. Move your code to app/src/main/rs
and Android Studio will build it properly and generate the .bc file asset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With