Run Java code from C++ using JNI (Android)

Hello,
I want to run some java code from C++ but every time I search for a java class using env->FindClass the application crashes telling me that the class do not exist. The class exist but somehow the JNIEnv that I get do not have access to the new java classes. How can I fix that?

To get the JNIENv I do the following:

JNIEnv* env = FAndroidApplication::GetJavaEnv();

I’ve also tried the following, but I go the same result:

JNIEnv* Env = NULL;
GJavaVM->GetEnv((void **)&Env, JNI_VERSION_1_6);
jint AttachThreadResult = GJavaVM->AttachCurrentThread(&Env, NULL);

Thanks for the help

Same issue here, I’m using this code but it doesn compile
http://www.codeproject.com/Articles/993067/Calling-Java-from-Cplusplus-with-JNI

It gets stuck in : jint rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);

if you find a solution please post, I am trying to implement GCM on my game but I can´t get the InstanceID of the app without java

My code compiles, it crashes during runtime, probably you have an other issue

I have the same issue. Don’t you solve this problem yet?

In my case, the problem was ProGuard tool. ProGuard encrypts names of Java classes to fight against decompilation and hacking. It also affects my normal codes trying to access Java classes. After I disabled ProGuard, the problem was solved.

You can configure ProGuard by editing a text file located in the path below.

Engine/Build/Android/Java/proguard-project.txt

For your information, 앱 축소, 난독화 및 최적화  |  Android 개발자  |  Android Developers