AOSP Keyboard: NoSuchMethodError - createEmptyDictFileNative

醉酒当歌 提交于 2019-12-12 01:47:21

问题


I'm trying to build the AOSP keyboard from the 5.0.2 branch after adding some custom code to obtain pressure values for key touches. I'm using lunch full-eng to build the source and using mm to build LatinIME after I've added my changes.

I was having trouble with pre-optimization but was helped here on how to solve that. I'm now having the following error:

E/dalvikvm(  729): ERROR: couldn't find native method
E/dalvikvm(  729): Requested: Lcom/android/inputmethod/latin/BinaryDictionary;.createEmptyDictFileNative:(Ljava/lang/String;J[Ljava/lang/String;[Ljava/lang/String;)Z
W/dalvikvm(  729): Exception Ljava/lang/NoSuchMethodError; thrown while initializing Lcom/android/inputmethod/latin/utils/JniUtils;
W/dalvikvm(  729): Exception Ljava/lang/NoSuchMethodError; thrown while initializing Lcom/android/inputmethod/latin/LatinIME;
W/dalvikvm(  729): Class init failed in newInstance call (Lcom/android/inputmethod/latin/LatinIME;)
D/AndroidRuntime(  729): Shutting down VM
W/dalvikvm(  729): threadid=1: thread exiting with uncaught exception (group=0x41f1ada0)
E/AndroidRuntime(  729): FATAL EXCEPTION: main
E/AndroidRuntime(  729): Process: com.android.inputmethod.latin, PID: 729
E/AndroidRuntime(  729): java.lang.NoSuchMethodError: no static or non-static method "Lcom/android/inputmethod/latin/BinaryDictionary;.createEmptyDictFileNative(Ljava/lang/String;J[Ljava/lang/String;[Ljava/lang/String;)Z"
E/AndroidRuntime(  729):    at java.lang.Runtime.nativeLoad(Native Method)
E/AndroidRuntime(  729):    at java.lang.Runtime.doLoad(Runtime.java:435)
E/AndroidRuntime(  729):    at java.lang.Runtime.loadLibrary(Runtime.java:363)
E/AndroidRuntime(  729):    at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime(  729):    at com.android.inputmethod.latin.utils.JniUtils.<clinit>(JniUtils.java:28)
E/AndroidRuntime(  729):    at com.android.inputmethod.latin.LatinIME.<clinit>(LatinIME.java:513)
E/AndroidRuntime(  729):    at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(  729):    at java.lang.Class.newInstance(Class.java:1208)
E/AndroidRuntime(  729):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2723)
E/AndroidRuntime(  729):    at android.app.ActivityThread.access$1900(ActivityThread.java:169)
E/AndroidRuntime(  729):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362)
E/AndroidRuntime(  729):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(  729):    at android.os.Looper.loop(Looper.java:146)
E/AndroidRuntime(  729):    at android.app.ActivityThread.main(ActivityThread.java:5487)
E/AndroidRuntime(  729):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  729):    at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(  729):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
E/AndroidRuntime(  729):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
E/AndroidRuntime(  729):    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
E/AndroidRuntime(  729):    at dalvik.system.NativeStart.main(Native Method)

LatinIME.java has the following comment regarding this call:

Loading the native library eagerly to avoid unexpected UnsatisfiedLinkError at the initial JNI call as much as possible.

And JniUtils.java makes the call

System.loadLibrary(JniLibName.JNI_LIB_NAME);

where JNI_LIB_NAME is supposedly defined in com.android.inputmethod.latin.define.JniLibName. This is where I believe my issue partially is.

  1. BinaryDictionary.java does not contain a createEmptyDictFileNave method
  2. com.android.inputmethod.latin.define.JniLibName does not exist in the source code I got from Google's repo.

Like always, any help would be greatly appreciated as I'm very new to Android source building. Thank you.

Regards,

Ian


回答1:


I just pulled up this searchon the package you're using and found that the class and method you're looking for do exist and for some reason you seem not to have it on your local repository.

Have you tried syncing/pulling the Google source code again? You may have git stash your changes before you sync (you can see the details of the command and its use here.

I'm doing some system app modification/creation as well and all the sources I needed were available when I built using mm.

My last suggestion would be to make sure you make the full-eng platform first once before you try compiling the LatinIME by itself. I had to do that for my app and I believe it will apply to your case too.

Best of luck - hope it turns out well!




回答2:


createEmptyDictFileNative is in BinaryDictionaryUtils and JNI_LIB_NAME is here.

You might have an outdated version of libjni_latinime.so that does not contain the createEmptyDictFileNative function exported for JNI.

Pull the library and verify that method exists:

adb pull /system/lib/libjni_latinime.so
nm -D libjni_latinime.so | grep createEmptyDictFile

If the library doesn't exist, you need to remount /system and install it. If the native method doesn't exist, you need an updated libjni_latinime.so shared library



来源:https://stackoverflow.com/questions/28102236/aosp-keyboard-nosuchmethoderror-createemptydictfilenative

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!