• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps cannot resolve corresponding jni function

mini139

Newbie
Apr 9, 2013
26
0
Hi,
I have gone through many posts and i couldn't find a solution till now. I am getting the warning message as "cannot resolve corresponding JNI function. Reports native method declaration in java where no corresponding JNI function is found in project." I tried using @SuppressWarnings("JniMissingFunction"). The warning went but it is not generation the .so file. I don't know where i am wrong. Please help me.
error1.png
 
Upvote 0
Actually that link isn't a very good guide. I reckon your problem is that the compiler hasn't loaded your native code, and I think you have the static code block to load the library in the wrong place.
Try this

Code:
// end of the class …
 static {
  System.loadLibrary("mainfn");
}
 public native String mainfn(....);
} // class MainActivity

https://medium.com/@ssaurel/create-your-first-jni-application-on-android-with-the-ndk-5f149508fb12
My gradle plugin is

classpath 'com.android.tools.build:gradle:1.5.0'
Following is my code.
The mainfn is redmarked in android-studio
Code:
public native String mainfn(String s, String inputtext, String wavname);
static
{
    System.loadLibrary("mainfn");
    Log.d(TAG,"Load libs finished");
}
 
Upvote 0
Posting my logcat for your reference.

09-12 10:29:29.830 7401-7401/? D/ToggleAccessibilityServicePreferenceFragment: mComponentName.getPackageName : com.example.vinay.screenreader
09-12 10:29:34.806 2908-2992/? D/MARsPolicyManager: getEnabledAccessibilityPackage: add mEnabledAccessibilityPackages com.example.vinay.screenreader
09-12 10:29:34.814 2908-2908/? I/AccessibilityManagerService: isTalkbackEnable : false, accesibilityService : com.example.vinay.screenreader/com.example.vinay.screenreader.MyScreenReaderService
09-12 10:29:34.851 7401-7401/? D/ToggleAccessibilityServicePreferenceFragment: mComponentName : ComponentInfo{com.example.vinay.screenreader/com.example.vinay.screenreader.MyScreenReaderService} false
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones