I want to add a new Java class in src/content/public/android/java/src/org/chromium/content/browser/ (say with name'MyClass.java'). The class will include some native methods. Currently I am not able to get the .h file to be created. This is what I do:
- In content_jni.gypi: add 'public/android/java/src/org/chromium/content/browser/MyClass.java' to sources
- In content_browser.gypi
- add 'public/browser/android/my_class.h' to variables
- add 'browser/android/my_class.h' and 'browser/android/my_class.cc', to android_browser_sources
- Then run ninja -C out/Release system_webview_apk
What am I missing here? What else do I need to be doing?
--Thanks very much!
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
--
Thanks Nico,Yes you're right, it actually worked and a file named MyClass_jni.h was created. Is this the file I should be including in my c++ code? The contents of it seemed a little odd to me, I was expecting something along the lines of aw_contents.h: https://code.google.com/p/chromium/codesearch#chromium/src/android_webview/native/aw_contents.h&q=aw_conten&sq=package:chromium&l=1Is this aw_contents.h not an automatically created file?
I thought for a java class named MyClass, I had to create my_class.cc and my_class.h would be autogenerated, and these would be linked together since they follow a naming convention, but it seems that I'm wrong. A little explanation on how I should be using JNI here would be great. I read the information on chromium website and that didn't help much.
Thanks!
On Thursday, April 28, 2016 at 9:46:46 PM UTC-5, Sarah wrote:I want to add a new Java class in src/content/public/android/java/src/org/chromium/content/browser/ (say with name'MyClass.java'). The class will include some native methods. Currently I am not able to get the .h file to be created. This is what I do:
- In content_jni.gypi: add 'public/android/java/src/org/chromium/content/browser/MyClass.java' to sources
- In content_browser.gypi
- add 'public/browser/android/my_class.h' to variables
- add 'browser/android/my_class.h' and 'browser/android/my_class.cc', to android_browser_sources
- Then run ninja -C out/Release system_webview_apk
What am I missing here? What else do I need to be doing?Thanks very much!
--
bool SupervisedUserContentProvider::Register(JNIEnv* env) { return RegisterNativesImpl(env); }
but who calls the Register() method? It does not seem to be invoked in the constructor.static base::android::RegistrationMethod kChromeRegisteredMethods[] = { <snip> {"SupervisedUserContentProvider", SupervisedUserContentProvider::Regi <snip>}; bool RegisterBrowserJNI(JNIEnv* env) { return RegisterNativeMethods(env, kChromeRegisteredMethods, arraysize(kChromeRegisteredMethods)); }
Hi,when I try to register I get "error: 'RegisteMyClass' is not a member of 'content'" error, even the this function exists in the namespace. I added "{"MyClass", content::RegisterMyClass}," to browser_jni_registrar.cc . What am I doing wrong?and this is how my cpp class looks like (my_class.cc):
static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jcaller, const JavaParamRef<jstring>& param); static jlong Java_org_chromium_example_jni_1generator_SampleForTests_nativeInit(JNIEnv* env, jobject jcaller, jstring param) { return Init(env, JavaParamRef<jobject>(env, jcaller), JavaParamRef<jstring>(env, param)); } static void Java_org_chromium_example_jni_1generator_SampleForTests_nativeDestroy(JNIEnv* env, jobject jcaller, jlong nativeCPPClass) { CPPClass* native = reinterpret_cast<CPPClass*>(nativeCPPClass); CHECK_NATIVE_PTR(env, jcaller, native, "Destroy"); return native->Destroy(env, JavaParamRef<jobject>(env, jcaller)); }