com/sun/jna/android-arm/libjnidispatch.so not foun

2019-07-01 18:48发布

问题:

All of the following is being done in Android Studio.

I have successfully compiled and tested the Android Watson Speech to Text demo app. I then created a library project containing the Watson related API's and a 2nd app project with a simple UI that references the Watson library project. The UI successfully starts and calls Watson speech to text api's. I thought I was set to use the Watson library project for real.

So I incorporated the Watson API project into my 'real' project. When I start the app connection to Watson I am getting:

E/AndroidRuntime: FATAL EXCEPTION: initStreamToServerThread
                   Process: com.sixflags.android, PID: 25481
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-arm/libjnidispatch.so) not found in resource path (.)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:786)                                                                              
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:746)                                                                            
at com.sun.jna.Native.<clinit>(Native.java:135)                                                                          
at com.sun.jna.NativeLibrary.<clinit>(NativeLibrary.java:82)                                                                          
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:337)                                                                          
at com.ibm.watson.developer_cloud.android.speech_to_text.v1.opus.JNAOpus.<clinit>(JNAOpus.java:42)                                                                         
at com.ibm.watson.developer_cloud.android.speech_to_text.v1.audio.OggOpusEnc.initEncoderWithUploader(OggOpusEnc.java:53)
at com.ibm.watson.developer_cloud.android.speech_to_text.v1.audio.WebSocketUploader.initStreamAudioToServer(WebSocketUploader.java:113)
at com.ibm.watson.developer_cloud.android.speech_to_text.v1.audio.WebSocketUploader.access$000(WebSocketUploader.java:46)
at com.ibm.watson.developer_cloud.android.speech_to_text.v1.audio.WebSocketUploader$2.run(WebSocketUploader.java:175) 

I have included speech-android-wrapper.aar in the libs directory and have included in the gradle.build dependencies:

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.ibm.watson.developer_cloud:java-sdk:2.10.0'
compile(name: 'speech-android-wrapper', ext: 'aar')

My app is rather large and is using multi-dex'ing so I am wondering if this could a clue to what is going wrong.

I did run into one other issue with a AndroidManifest.xml manifest conflict in the application section that I resolved with adding:

tools:replace="android:icon,android:name"

I don't see how that could cause the link error but just throwing it out there in case I am missing the significance of it.

Looking for suggestions.

回答1:

If you're referencing the module of "speech-android-wrapper", please use this configuration in your gradle:

compile project(':speech-android-wrapper')

If you're using AAR libs, please try this:

dependencies {
  //...
  debugCompile(name:'speech-android-wrapper-debug', ext:'aar')
  releaseCompile(name:'speech-android-wrapper-release', ext:'aar')
}

...

repositories{
  //...
  flatDir{
    dirs 'libs'
  }
}

Icon issue was resolved already in another repo, will be merged to the Watson Developer Cloud repo soon.

Hope it helps.