Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4606894
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:37:40+00:00 2026-05-22T00:37:40+00:00

Is JNI’s method signature different if method is defined to return (static) interface ?

  • 0

Is JNI’s “method signature” different if method is defined to return (static) interface ?

In my Java class I have this method:

public SharedPreferences.Editor getSharedPrefsEditor() {
    return mActivity.getPreferences(Context.MODE_PRIVATE).edit();
}

SharedPreferences.Editor is a static interface in SharedPreferences.

In my C++ JNI code I do this:

// 'env' is the java environment that JNI passes to us
// 'jObject' is the one that JNI passes to us (along with env)
jclass javaCallerClass = env->GetObjectClass(jObject);
jmethodID methodId_getSharedPrefsEditor = env->GetMethodID(
    javaCallerClass,
    "getSharedPrefsEditor",
    "()Landroid/content/SharedPreferences/Editor;");

For some odd reason, this doesn’t work. It compiles, but at runtime I get this:

DEBUG/dalvikvm(19020): GetMethodID:
method not found:
Lcom/mangotaster/madballs/MyRenderer;.getSharedPrefsEditor:()Landroid/content/SharedPreferences/Editor;

I’m calling other methods in that class in pretty much the same way without any problems.

The only change seems to be the return value.
I did try to call the edit() function straight from JNI code, but got the same error – which makes me believe that my function signature “()Landroid/content/SharedPreferences/Editor;” is indeed wrong.

More info on the SharedPreferences class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:37:41+00:00Added an answer on May 22, 2026 at 12:37 am

    Nested/Inner classes don’t use the standard namespace nomenclature in JNI signatures. The inner class is actually translated to a normal class at the same level as the outer class by the Java compiler with the name “Outer$Inner”. I think you want "()Landroid/content/SharedPreferences$Editor;".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My java app uses JNI to invoke a library written in C. This native
When using JNI to interface between Java and C, javah parses a boolean value
I'm just about to make my first trip into the world of JNI (Java
JNI tutorials, for instance this one, cover quite well how to access primitive fields
I have written some JNI hooks into a C++ library and created some DLL
I use Java JNI with Gdal . There are some server side applications built
In JNI when we want to pass a string from C to java we
When compiling my Android JNI project, I got this error: make: Circular /obj/local/armeabi/libstlport_static.a <-
I want to create .dll with java jni. My .cpp file refers to an
I am currently writting a JNI wrapper for a C++ class and I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.