I'm following a guide for beginners with android NDK.
And I'm a little stuck. The resumed problem is: I have an Java class with some native methods. When I try to create the C Header File using javah and type:
javah -jni com.droidonfire.DroidOnFire
And it returns
Error: cannot access android.view.SurfaceView
class file for android.view.SurfaceView not found
Where is the problem?
Thanks
The class DroidOnFire:
public class DroidOnFire extends SurfaceView implements SurfaceHolder.Callback{
private boolean mEnabled;
private Paint mTextPaint;
private Paint mTextOffPaint;
private Paint mCanvasPaint;
private Bitmap mEffect;
private Canvas mEffectCanvas;
public DroidOnFire(Context context, AttributeSet attrs) {
super(context, attrs);
getHolder().addCallback(this);
mEnabled= false;
initialize();
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
mEffect= Bitmap.createBitmap(width,200,Bitmap.Config.ARGB_8888);
mEffectCanvas= new Canvas(mEffect);
}
public void surfaceCreated(SurfaceHolder holder) {
setKeepScreenOn(true);
setWillNotDraw(false);
mTextPaint= new Paint();
mTextPaint.setTextSize(32.0f);
mTextPaint.setColor(Color.WHITE);
mTextOffPaint = new Paint();
mTextOffPaint.setColor(Color.BLACK);
mTextOffPaint.setTextSize(32.0f);
mCanvasPaint= new Paint();
mEnabled= true;
}
public void surfaceDestroyed(SurfaceHolder holder) {
mEnabled= false;
mEffect.recycle();
mEffect=null;
mEffectCanvas=null;
}
@Override
public void draw(Canvas canvas) {
if (mEnabled){
String lMessage=getMessage();
mEffectCanvas.drawText(lMessage, 0, 32, mTextOffPaint);
updateFire(mEffect);
canvas.drawBitmap(mEffect, 0, 0,mCanvasPaint);
canvas.drawText(lMessage, 0, 32, mTextPaint);
initialize();
}
}
private native void initialize();
private native String getMessage();
private native void updateFire(Bitmap pBitmap);
static {
System.loadLibrary("fire");
}
}