Log in or register to post comments

Adding try catch to native code

June 10, 2014 - 2:10am #1

I am getting an exception from the native code .

With the stack trace i am not getting much info than the function name.

So i am trying to add a try catch to throw a java exception .

Is this possible

i added 

try{

 

}

catch (const std::exception& e)                                 \
     {                                                               \
       /* unknown exception */                                       \
       jclass jc = env->FindClass("java/lang/Error");                \
       if(jc) env->ThrowNew (jc, e.what());                          \
     }
to  Java_com_idg_reelbillboard_CloudRecognition_CloudReco_enterScanningModeNative function
 
But on compilation i am getting  
 
Compile++ arm    : CloudReco <= CloudReco.cpp
jni/CloudReco.cpp: In function 'void Java_com_idg_reelbillboard_CloudRecognition_CloudReco_enterScanningModeNative(JNIEnv*, _jobject*)':
jni/CloudReco.cpp:737: error: expected unqualified-id before '&' token
jni/CloudReco.cpp:737: error: exception handling disabled, use -fexceptions to enable
jni/CloudReco.cpp:737: error: expected ')' before '&' token
jni/CloudReco.cpp:737: error: expected '{' before '&' token
jni/CloudReco.cpp:737: error: 'e' was not declared in this scope
jni/CloudReco.cpp:737: error: expected ';' before ')' token
/cygdrive/c/Users/IDG3/android-ndk-r8-windows/android-ndk-r8/build/core/build-binary.mk:243: recipe for target `obj/local/armeabi/objs/CloudReco/CloudReco.o' failed
make: *** [obj/local/armeabi/objs/CloudReco/CloudReco.o] Error 1
 
 
Please help on why it is coming. Is it possible to add and if yes am i doing it wrong 

 

Log in or register to post comments