Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.10
more ▼

asked Nov 30 '15 at 06:14 PM in C++ Programming

avatar image

16 1 3 3

avatar image Gandore Dec 01 '15 at 03:35 AM

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

avatar image joanpuigsanz Dec 01 '15 at 08:12 AM

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

avatar image Solvay Mar 15 '16 at 10:40 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.


For your information, http://developer.android.com/intl/ko/tools/help/proguard.html#configuring

more ▼

answered Mar 25 '16 at 08:15 AM

avatar image

29 1 4 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question