I know how to use the JNI to call a java method in C++, but I'm having troubles getting the program to find the class.
Here's my code:
Code: Select all
JNIEnv* env = 0;
app->activity->vm->AttachCurrentThread(&env, NULL);
jclass myClass = env->FindClass("com/Game/app/Game");
if (myClass == 0) {
return;
}
Game::log("OK.\n");
jmethodID mid = env->GetMethodID(myClass, "getOpenFileName", "()V"); // porting "getOpenFileName" to Android
if (mid == 0)
Game::log("COULDN'T FIND METHOD.\n");
jstring hundred = (jstring)env->CallObjectMethod(myClass, mid);
app->activity->vm->DetachCurrentThread();
If I look for a different class, I.E
Code: Select all
jclass myClass = env->FindClass("java/io/File");
The exact error I receive is
Code: Select all
01-05 01:13:12.937 8976 8976 F DEBUG : Abort message: 'thread.cc:2090] No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "com.Game.app.Game" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /system/lib]]'
Finally, here is my Java code:
Code: Select all
package com.Game.app;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.WindowManager;
import android.view.View;
import android.net.Uri;
public class Game extends android.app.NativeActivity {
// other methods that aren't relevant to this question
public void getOpenFileName()
{
Intent intent = new Intent().setType("*/*").setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select a file"), 123);
}
}
Suggestions would be appreciated.