1

I'm building LatinIME source code provided by google-source in android-studio but i got a bug in ProximityInfo.java line 89 which show a dialog like this and i have added a jni_latinime.so in src/main/jniLibs like this. But the bug is still not fixed.What mistake i did and what should i have to do now?

Error

droid.inputmethod.latin E/JniUtils: Could not load native library jni_latinime
   java.lang.UnsatisfiedLinkError: unknown failure
       at java.lang.Runtime.loadLibrary(Runtime.java:370)
       at java.lang.System.loadLibrary(System.java:535)
       at com.android.inputmethod.latin.utils.JniUtils.<clinit>(JniUtils.java:28)
       at com.android.inputmethod.latin.LatinIME.<clinit>(LatinIME.java:546)
       at java.lang.Class.newInstanceImpl(Native Method)
       at java.lang.Class.newInstance(Class.java:1319)
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:2406)
       at android.app.ActivityThread.access$1700(ActivityThread.java:140)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4944)
       at java.lang.reflect.Method.invokeNative(Native Method)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
       at dalvik.system.NativeStart.main(Native Method)
05-28 21:58:48.483 1642-1957/system_process E/InputMethodManagerService: checkCscDefaultIme : mCscDefaultImePackageName is wrong
05-28 21:58:48.493 1642-1957/system_process E/InputMethodManagerService: checkCscDefaultIme : mCscDefaultImePackageName is wrong
05-28 21:58:48.834 12819-12819/com.android.inputmethod.latin E/dalvikvm: Could not find class 'android.os.UserManager', referenced from method com.android.inputmethod.compat.UserManagerCompatUtils.<clinit>
05-28 21:58:48.844 12819-12819/com.android.inputmethod.latin E/dalvikvm: Could not find class 'android.os.UserManager', referenced from method com.android.inputmethod.compat.UserManagerCompatUtils.getUserLockState
05-28 21:58:48.954 12819-12819/com.android.inputmethod.latin E/AndroidRuntime: FATAL EXCEPTION: main
  android.view.InflateException: Binary XML file line #2: Error inflating class com.android.inputmethod.keyboard.emoji.EmojiPalettesView
      at android.view.LayoutInflater.createView(LayoutInflater.java:619)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:818)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
      at com.android.inputmethod.keyboard.KeyboardSwitcher.onCreateInputView(KeyboardSwitcher.java:464)
      at com.android.inputmethod.latin.LatinIME.onCreateInputView(LatinIME.java:752)
      at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:1227)
      at android.inputmethodservice.InputMethodService.showWindowInner(InputMethodService.java:1628)
      at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:1595)
      at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:521)
      at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:192)
      at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:4944)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
      at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.reflect.InvocationTargetException
      at java.lang.reflect.Constructor.constructNative(Native Method)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
      at android.view.LayoutInflater.createView(LayoutInflater.java:593)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693) 
      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:818) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
      at com.android.inputmethod.keyboard.KeyboardSwitcher.onCreateInputView(KeyboardSwitcher.java:464) 
      at com.android.inputmethod.latin.LatinIME.onCreateInputView(LatinIME.java:752) 
      at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:1227) 
      at android.inputmethodservice.InputMethodService.showWindowInner(InputMethodService.java:1628) 
      at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:1595) 
      at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:521) 
      at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:192) 
      at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61) 
      at android.os.Handler.dispatchMessage(Handler.java:99) 
      at android.os.Looper.loop(Looper.java:137) 
      at android.app.ActivityThread.main(ActivityThread.java:4944) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:511) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 
      at dalvik.system.NativeStart.main(Native Method) 
   Caused by: java.lang.UnsatisfiedLinkError: Native method not found: com.android.inputmethod.keyboard.ProximityInfo.setProximityInfoNative:(IIIIII[II[I[I[I[I[I[F[F[F)J
      at com.android.inputmethod.keyboard.ProximityInfo.setProximityInfoNative(Native Method)
      at com.android.inputmethod.keyboard.ProximityInfo.createNativeProximityInfo(ProximityInfo.java:222)
      at com.android.inputmethod.keyboard.ProximityInfo.<init>(ProximityInfo.java:81)
      at com.android.inputmethod.keyboard.Keyboard.<init>(Keyboard.java:123)
      at com.android.inputmethod.keyboard.internal.KeyboardBuilder.build(KeyboardBuilder.java:196)
      at com.android.inputmethod.keyboard.KeyboardLayoutSet.getKeyboard(KeyboardLayoutSet.java:232)
      at com.android.inputmethod.keyboard.KeyboardLayoutSet.getKeyboard(KeyboardLayoutSet.java:204)
      at com.android.inputmethod.keyboard.emoji.EmojiCategory.getKeyboard(EmojiCategory.java:374)
      at com.android.inputmethod.keyboard.emoji.EmojiCategory.addShownCategoryId(EmojiCategory.java:223)
      at com.android.inputmethod.keyboard.emoji.EmojiCategory.<init>(EmojiCategory.java:176)
      at com.android.inputmethod.keyboard.emoji.EmojiPalettesView.<init>(EmojiPalettesView.java:120)
      at com.android.inputmethod.keyboard.emoji.EmojiPalettesView.<init>(EmojiPalettesView.java:96)
      at java.lang.reflect.Constructor.constructNative(Native Method) 
      at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
      at android.view.LayoutInflater.createView(LayoutInflater.java:593) 
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693) 
      at android.view.LayoutInflater.parseInclude(LayoutInflater.java:818) 
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
      at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
      at com.android.inputmethod.keyboard.KeyboardSwitcher.onCreateInputView(KeyboardSwitcher.java:464) 
      at com.android.inputmethod.latin.LatinIME.onCreateInputView(LatinIME.java:752) 
      at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:1227) 
      at android.inputmethodservice.InputMethodService.showWindowInner(InputMethodService.java:1628) 
      at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:1595) 
      at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:521) 
      at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:192) 
      at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61) 
      at android.os.Handler.dispatchMessage(Handler.java:99) 
      at android.os.Looper.loop(Looper.java:137) 
      at android.app.ActivityThread.main(ActivityThread.java:4944) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:511) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 
      at dalvik.system.NativeStart.main(Native Method) 
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
Sawal Timsina
  • 69
  • 1
  • 10

2 Answers2

3

Your screenshot suggests that your jniLibs contains a jar file with prebuilt native library. I did not know that this is even possible, but yes, it works in Android Studio 2.3 and higher. Nice!

Anyways, as I explained elsewhere, don't expect Android Studio to resolve magically the native method declarations into a prebuilt library (even if it is unpacked into src/main/jnLibs).

You can simply ignore this error message: your APK will still install the prebuilt library, and the native method will be resolved at run time.

You can add @SuppressWarnings("JniMissingFunction") annotation for this method, or for the entire class:

@SuppressWarnings("JniMissingFunction")
public class ProximityInfo {

or configure this kind of Lint inspections for the given project, or for all projects: Preferences/Editor/Inspections

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • I did as like you said but that didn't worked.when i run the app i get error.I have included the error in question,please review it.thanks – Sawal Timsina May 28 '17 at 16:12
  • OK, this is a very different story. If we believe the error message you posted, **libjni_latinime.so** could not load. If the file is present in your APK (use Android Studio *analyze APK* to check), then maybe it does not fit your device. Which device do you use? – Alex Cohn May 28 '17 at 18:17
  • I use lenovo thinkpad laptop and samsung galaxy fame smartphone.i don't think it is depended on devices. – Sawal Timsina May 31 '17 at 06:05
  • Samsung Galaxy Fame S6810P is 4 years old, and has a very old preloaded OS 4.1.2. Make sure that your **libjni_latinime.so** was built compatible with this platform. – Alex Cohn Jun 01 '17 at 08:10
  • 1
    As far as I can understand, you built LatinIME package in Android Studio from GIT source. But I don't understand how you 'run' it on the device. Did you replace the system library with the one you built? Did you include this library in your application? Neither of these approaches will work, because LatinIME is an integral part of the Android OS. – Alex Cohn Jun 03 '17 at 19:28
1

This is very old query and hopefully must have been solved by now. But still wanted to put my comment on this.

As I can see this is a run time error and related to "UnsatisfiedLinkError", which means that the application is unable to link to the library that it is looking for. Hence the library "latimime" is missing when the application is bundled.

To make sure that the library is bundled along with the application, you can extract the APK and check.

View bundled library in Android Studio

Rajan
  • 292
  • 2
  • 10
  • if it is not getting bundled which I have in my case, How do I make it sure get bundled? In my case I have `aab` file and when I checked whether the `latinime_jni.so` is existing or not, it is existing in both of the `abi's` and still it is causing the issue – Zaraki596 May 05 '22 at 08:24