2017-05-27 66 views
0

我建立由google-source在Android的工作室提供LatinIME的源代碼,但我得到了在ProximityInfo.java線89顯示一個對話框like this一個錯誤,我添加了一個jni_latinime.sosrc/main/jniLibs like this。 但錯誤仍然沒有解決。我做了什麼錯誤,現在該怎麼辦?無法解析對應JNI功能Java_com_android_inputmethod_keyboard_ProximityInfo_setProximityInfoNative

錯誤

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)  

回答

1

你的截圖表明您jniLibs包含JAR文件與預建的機庫。我不知道這甚至可能,但是,它可以在Android Studio 2.3及更高版本中使用。太好了!

不管怎麼說,正如我所解釋的elsewhere,不要指望Android Studio神奇地將原生方法聲明解析爲預構建庫(即使解壓縮到src/main/jnLibs)。

您可以簡單地忽略此錯誤消息:您的APK仍將安裝預建庫,並且本機方法將在運行時解析。

您可以添加@SuppressWarnings("JniMissingFunction")註解此方法,或者爲整個類:

@SuppressWarnings("JniMissingFunction") 
public class ProximityInfo { 

或配置這種皮棉檢查對於給定的項目,或所有項目: Preferences/Editor/Inspections

+0

我做就像你說的,但沒有奏效。當我運行應用程序時,我得到錯誤。我已經包括有問題的錯誤,請檢查它。謝謝 –

+0

好吧,這是一個非常不同的故事。如果我們相信您發佈的錯誤消息,** libjni_latinime.so **無法加載。如果該文件存在於您的APK中(使用Android Studio *分析APK *進行檢查),那麼它可能不適合您的設備。你使用哪種設備? –

+0

我使用聯想thinkpad筆記本電腦和三星銀河名氣智能手機。我不認爲這是依賴於設備。 –