2011-10-27 19 views
1

android NDKの初心者のためのガイドに従っています。エラー:android.view.SurfaceViewにアクセスできません

私はちょっと立ち往生しています。再開された問題は次のとおりです。私はいくつかのネイティブメソッドを持つJavaクラスを持っています。 私はjavahはとタイプを使用してCヘッダ・ファイルを作成しようとすると:

javah -jni com.droidonfire.DroidOnFire 

そして、それは

Error: cannot access android.view.SurfaceView 
class file for android.view.SurfaceView not found 

問題があるを返しますか?

おかげ

クラス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"); 
} 

}

答えて

2

あなたはjavahはを呼び出すときにドキュメントを参照してくださいhere、-classpath引数を指定する必要があります。

classpath path 
    Specifies the path javah uses to look up classes. Overrides the default or the CLASSPATH environment variable if it is set. Directories are separated by semi-colons. Thus the general format for path is: 
     .;<your_path> 
    For example: 
     .;C:\users\dac\classes;C:\tools\java\classes 

あなたの場合、クラスパスにandroid.jarを追加する必要があります。

回答は同様の質問hereです。

関連する問題