Cannot Resolve Corresponding JNI Function Java_com_android_inputmethod_keyboard_ProximityInfo_setProximityInfoNative
我正在构建由 google-source 在 android-studio 中提供的 LatinIME 源代码,但我在 ProximityInfo.java 第 89 行中遇到了一个错误,它显示了一个对话框 ,我添加了一个 jni_latinime.so
在 src/main/jniLibs
。
但是这个bug还没有修复。我犯了什么错误,我现在应该做什么?
错误
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | 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)? |
您的屏幕截图表明您的 jniLibs 包含一个带有预构建本机库的 jar 文件。我什至不知道这是可能的,但是是的,它适用于 Android Studio 2.3 及更高版本。不错!
无论如何,正如我在别处解释的那样,不要指望 Android Studio 会神奇地将本机方法声明解析为预构建库(即使它已解压缩到
您可以直接忽略此错误消息:您的 APK 仍将安装预构建库,并且本机方法将在运行时解析。
你可以为这个方法添加
1 2 | @SuppressWarnings("JniMissingFunction") public class ProximityInfo { |
或为给定项目或所有项目配置这种 Lint 检查:
这是一个非常古老的查询,希望现在已经解决了。但仍然想对此发表评论。
正如我所见,这是一个运行时错误,与"UnsatisfiedLinkError"有关,这意味着应用程序无法链接到它正在寻找的库。因此,捆绑应用程序时缺少库"latimime"。
为确保该库与应用程序捆绑在一起,您可以提取 APK 并检查。