2

I am working on an app in android where I have a Java class containing android.graphics.Bitmap package

I want to create a header file using javah but getting an error:

Class android.graphics.Bitmap not found
Mat
  • 202,337
  • 40
  • 393
  • 406
dave21
  • 315
  • 1
  • 6
  • 14
  • What exactly are you trying to do? C/C++ doesn't know anything about java packages. – sschrass Mar 03 '12 at 11:10
  • when we actually work on Android-nDK, our java class needs to b converted into a header file that we can put in our jni folder.....Hope u know all dat. the real prob is we can create a header file from a java class but if we put android package into dat java class...it creates a problem – dave21 Mar 03 '12 at 11:28
  • No. Header files are C++, java packages are java. Your java-class needs to call C/C++ methods through jni. Thats what jni is for. So why do you want to put your java class in a C++ header file? – sschrass Mar 03 '12 at 15:05
  • Try this (Answer 1) [http://stackoverflow.com/questions/4273168/javah-not-able-to-find-android-classes][1] [1]: http://stackoverflow.com/questions/4273168/javah-not-able-to-find-android-classes – sschrass Mar 05 '12 at 07:37

1 Answers1

0

I think you are trying to develop an openCV app.

So you basically want to call methods from the openCV library, that are not implemented in java yet, but are available as native C or C++ methods. Try to circumvent that, because jni-calls are expensive.

#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <vector>

using namespace std;
using namespace cv;

extern "C" {
JNIEXPORT void JNICALL Java_[your]_[package]_[com]_[class]_[method](JNIEnv* env, jobject thiz, jlong addrGray, jlong addrRgba)
{
//do stuff
}

you can call this method now from your java class:

public native void method(long matAddrGr, long matAddrRgba);
sschrass
  • 7,014
  • 6
  • 43
  • 62
  • Yeah...actually I am trying to create my own PdfViewer using muPdf library..So In the java class where we load the native library.."muPdf", we have the android.graphics.Bitmap and have to create ".h" file for the java class – dave21 Mar 05 '12 at 04:33