0

I build Android NDK application in Android Studio. I've subclassed NativeActivity to add some Java code into my app. And I can't get this activity class with JNIEnv::FindClass on the C++ side. I know that:

  1. I can call FindClass in Java thread only (I do so)
  2. I should use full /-separated path to my class (/com/my_package/MyActivity)
  3. The class should be public (not sure if it really should, but it is public, just in case)

Also, FindClass for "built-in" classes, like android/net/Uri, android/content/Intent, etc works fine. I can call Java methods from C++ - all that works fine. However FindClass for my own class doesn't work.

Googling for the similar errors didn't match my case. At least nothing helped from what I found. I work in Windows 7 (not sure if it matters).

nyan-cat
  • 610
  • 5
  • 19
  • 3
    I hope you mean `com/my_package/MyActivity` without the leading slash. Anyway, see https://stackoverflow.com/questions/14586821/android-flurry-integration-with-ndk-app – Michael Oct 31 '19 at 20:41
  • Yea, sorry, just a typo. No leading slashes in my code. Thank you for the link, looks promising. I'll try it tomorrow and get back here with results. – nyan-cat Oct 31 '19 at 21:52
  • Hey Michael. Thank you very much, that's exactly my case, the problem is solved! A pity that I can't mark a comment as a solution to the question! – nyan-cat Nov 01 '19 at 19:36

0 Answers0