我一直在尝试这个很长一段时间。我必须尝试过数百种不同的方法来使其发挥作用,但尚未取得成功。让我来描述我想要做的事情。
我有一个由第三方组织提供的名为“androidservice”的Android库项目。由于它是一个源项目较近的项目,因此项目仅包含相关的.jar文件及其资源,如下面的项目层次结构所示。 (请注意,实际的.jar文件位于libs文件夹中。我假设bin文件夹中的文件没有用,因为它的大小非常小,只有166byte,我认为它是在项目得到时从空源生成的建)。
我想在Xamarin中使用这个“androidservice”库项目,我多次阅读http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/上的说明
我在Xamarin中创建了一个Android Java绑定库,并根据上面链接的文章的最后一部分添加了一个zip文件。绑定项目的结构如下所示。
其中thirdparty.zip包含“androidservice”项目的 bin 文件夹和 res 文件夹。
现在,因为bin文件夹中的原始androidservice.jar似乎不是正确的(仅166字节)并且使用此jar文件,绑定项目会出现错误“必须至少指定一个输入jar “在构建过程中,我用libs文件夹中的”androidservice.jar“替换了这个小jar,它有一个更大的845kb大小。 Jars文件夹中的jar文件都设置为“EmbeddedReferenceJar”。
然后我在我的Xamarin android项目中通过在引用中添加它来引用这个绑定库。
通过这个设置,绑定库和android项目都会构建。但是,在Android手机上以调试模式运行应用程序时,会显示错误消息:
[AndroidRuntime] java.lang.UnsatisfiedLinkError: Couldn't load opus from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.company.myApp-1.apk,libraryPath=/data/app-lib/com.company.myApp-1]: findLibrary returned null
[AndroidRuntime] at java.lang.Runtime.loadLibrary(Runtime.java:358)
[AndroidRuntime] at java.lang.System.loadLibrary(System.java:526)
[AndroidRuntime] at com.thirdparty.eptt.android.service.RealVoice$3.run(RealVoice.java:194)
opus这个词似乎暗示它与libopus.so有关。
我查看了下面的所有链接,但都没有帮助。 http://forums.xamarin.com/discussion/8773/how-to-handle-so-libs-in-java-bindings-library
http://forums.xamarin.com/discussion/6088/loading-native-library
对可能的解决方案或进一步调试方法的任何建议都将不胜感激。
完整输出:
[SELinux] Function: selinux_android_load_priority [0], There is no sepolicy file.
[SELinux]
[SELinux] Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_GT-I9505_4.4.2_0032
[SELinux]
[SELinux]
[SELinux] selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8846,server=y,embedding=1
[libc] WARNING: generic atexit() called from legacy shared library
[Mono] Image addref mscorlib[0x7257ce00] -> mscorlib.dll[0x7257c230]: 1
[Mono] AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/data/com.company.myApp/lib/mscorlib.dll.so" not found
[Mono] Assembly mscorlib[0x7257ce00] added to domain RootDomain, ref_count=1
[Mono] Assembly Loader probing location: '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/MyAppAndroid.dll'.
[Mono] Image addref MyAppAndroid[0x728c7eb0] -> /storage/emulated/0/Android/data/com.company.myApp/files/.__override__/MyAppAndroid.dll[0x728c72e8]: 2
[Mono] Assembly MyAppAndroid[0x728c7eb0] added to domain RootDomain, ref_count=1
[Mono] AOT module '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/MyAppAndroid.dll.so' not found: dlopen failed: library "/data/data/com.company.myApp/lib//storage/emulated/0/Android/data/com.company.myApp/files/.__override__/MyAppAndroid.dll.so" not found
[Mono] Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/MyAppAndroid.dll'.
[Mono] Config attempting to parse: '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/MyAppAndroid.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/builds/install/mono-armv7/etc/mono/assemblies/MyAppAndroid/MyAppAndroid.config'.
[Mono] Assembly Loader probing location: '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/Bindings.dll'.
[Mono] Image addref Bindings[0x728cce50] -> /storage/emulated/0/Android/data/com.company.myApp/files/.__override__/Bindings.dll[0x728cc228]: 2
[Mono] Assembly Bindings[0x728cce50] added to domain RootDomain, ref_count=1
[Mono] AOT module '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/Bindings.dll.so' not found: dlopen failed: library "/data/data/com.company.myApp/lib//storage/emulated/0/Android/data/com.company.myApp/files/.__override__/Bindings.dll.so" not found
[Mono] Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/Bindings.dll'.
[Mono] Config attempting to parse: '/storage/emulated/0/Android/data/com.company.myApp/files/.__override__/Bindings.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/builds/install/mono-armv7/etc/mono/assemblies/Bindings/Bindings.config'.
[monodroid-gc] GREF GC Threshold: 46800
[Mono] Image addref Mono.Android[0x728cc1c8] -> Mono.Android.dll[0x72904328]: 1
[Mono] Assembly Mono.Android[0x728cc1c8] added to domain RootDomain, ref_count=1
[Mono] AOT module 'Mono.Android.dll.so' not found: dlopen failed: library "/data/data/com.company.myApp/lib/Mono.Android.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0x728cc1c8] -> mscorlib[0x7257ce00]: 2
[Mono] Assembly Ref addref Bindings[0x728cce50] -> mscorlib[0x7257ce00]: 3
[Mono] Assembly Ref addref Bindings[0x728cce50] -> Mono.Android[0x728cc1c8]: 2
[Mono] Image addref System.Core[0x7c6e5548] -> System.Core.dll[0x7c6daf18]: 1
[Mono] Assembly System.Core[0x7c6e5548] added to domain RootDomain, ref_count=1
[Mono] AOT module 'System.Core.dll.so' not found: dlopen failed: library "/data/data/com.company.myApp/lib/System.Core.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0x728cc1c8] -> System.Core[0x7c6e5548]: 2
[Mono] Assembly Ref addref System.Core[0x7c6e5548] -> mscorlib[0x7257ce00]: 4
[Mono] Assembly Ref addref MyAppAndroid[0x728c7eb0] -> Mono.Android[0x728cc1c8]: 3
[Mono] Assembly Ref addref MyAppAndroid[0x728c7eb0] -> mscorlib[0x7257ce00]: 5
[Mono] Assembly Ref addref MyAppAndroid[0x728c7eb0] -> Bindings[0x728cce50]: 2
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_new'.
[Mono] Probing '_monodroid_gref_log_new'.
[Mono] Found as '_monodroid_gref_log_new'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Probing '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Found as '_monodroid_gc_wait_for_bridge_processing'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_get_identity_hash_code'.
[Mono] Probing '_monodroid_get_identity_hash_code'.
[Mono] Found as '_monodroid_get_identity_hash_code'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_delete'.
[Mono] Probing '_monodroid_gref_log_delete'.
[Mono] Found as '_monodroid_gref_log_delete'.
[DemoActivity] OnCreate: start
[DemoActivity] OnCreate: Core Service is not running.. ViewInitializing
[DemoActivity] viewInitializing
[ProgressBar] setProgressDrawable drawableHeight = 18
[Mono] Image addref System.Xml[0x7c909a38] -> System.Xml.dll[0x7c908f68]: 1
[Mono] Assembly System.Xml[0x7c909a38] added to domain RootDomain, ref_count=1
[Mono] AOT module 'System.Xml.dll.so' not found: dlopen failed: library "/data/data/com.company.myApp/lib/System.Xml.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0x728cc1c8] -> System.Xml[0x7c909a38]: 2
[Mono] Assembly Ref addref System.Xml[0x7c909a38] -> mscorlib[0x7257ce00]: 6
[DemoActivity] onCreate, installer: , False
[DemoActivity] onResume DemoActivity
[DemoActivity] onResume -> Service is not bound
[Adreno-EGL] <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: (CL3869936)
[Adreno-EGL] OpenGL ES Shader Compiler Version: 17.01.11.SPL
[Adreno-EGL] Build Date: 01/17/14 Fri
[Adreno-EGL] Local Branch:
[Adreno-EGL] Remote Branch:
[Adreno-EGL] Local Patches:
[Adreno-EGL] Reconstruct Branch:
[OpenGLRenderer] Enabling debug mode 0
[DemoActivity] CoreStarterRunnable : Run. Trying to bind
[ContextImpl] Failed to ensure directory: /storage/extSdCard/Android/data/com.company.myApp/files
[RU] getDebugDirectoryName:/storage/emulated/0/Android/data/com.company.myApp/files
[Debugger] openNewFile: 0, append: true
[CHATAPP] 11:35:31.821: WARN: SERV CHATAPP: Starting Version 1.0 (Build 300)
[CHATAPP] 11:35:31.829: ERROR: SERV error reading config file: java.io.FileNotFoundException: /data/data/com.company.myApp/files/config.json: open failed: ENOENT (No such file or directory)
[CHATAPP] 11:35:31.830: DEBUG: SERV readConfig
[CHATAPP] 11:35:31.830: DEBUG: SERV config file does not exist
[CHATAPP] 11:35:31.834: DEBUG: RDB DB: Filesystem root:
[CHATAPP] 11:35:31.834: DEBUG: SERV register media button
[CHATAPP] 11:35:31.835: DEBUG: SERV create Savox PTT
[CHATAPP] 11:35:31.852: DEBUG: SERV getMetaDataString: floorDenyTone: null
[CHATAPP] 11:35:31.853: DEBUG: SERV getMetaDataString: rxNewMessageTone: null
[CHATAPP] 11:35:31.859: DEBUG: RV registerHeadsetReceiver
[CHATAPP] 11:35:31.861: DEBUG: HR onReceive
[CHATAPP] 11:35:31.863: DEBUG: RV isBluetoothAllowed: false
[CHATAPP] 11:35:31.865: DEBUG: SERV setImplicitDnd: old=false, RM=1
[CHATAPP] 11:35:31.866: ERROR: SERV error reading config file: java.io.FileNotFoundException: /data/data/com.company.myApp/files/config.json: open failed: ENOENT (No such file or directory)
[CHATAPP] 11:35:31.866: DEBUG: SERV readConfig
[CHATAPP] 11:35:31.867: DEBUG: SERV config file does not exist
[CHATAPP] 11:35:31.867: DEBUG: RV requestAudioFocus force=true
[CHATAPP] 11:35:31.871: DEBUG: RV Got audio focus
[CHATAPP] 11:35:31.879: ERROR: SERV error reading config file: java.io.FileNotFoundException: /data/data/com.company.myApp/files/config.json: open failed: ENOENT (No such file or directory)
[CHATAPP] 11:35:31.880: DEBUG: SERV readConfig
[CHATAPP] 11:35:31.887: DEBUG: SERV config file does not exist
[CHATAPP] 11:35:31.889: DEBUG: SERV getMetaDataBoolean: useVoicePrivacy: false
[CHATAPP] 11:35:31.891: DEBUG: CO Construct
[CHATAPP] 11:35:31.892: DEBUG: SERV LMR: createNetwork:
[AndroidRuntime] FATAL EXCEPTION: Thread-844
[AndroidRuntime] Process: com.company.myApp, PID: 2323
[AndroidRuntime] java.lang.UnsatisfiedLinkError: Couldn't load opus from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.company.myApp-1.apk,libraryPath=/data/app-lib/com.company.myApp-1]: findLibrary returned null
[AndroidRuntime] at java.lang.Runtime.loadLibrary(Runtime.java:358)
[AndroidRuntime] at java.lang.System.loadLibrary(System.java:526)
[AndroidRuntime] at com.thirdparty.eptt.android.service.RealVoice$3.run(RealVoice.java:194)
[CHATAPP] 11:35:31.894: DEBUG: MDB getUnopenedMessageCount
[CHATAPP] 11:35:31.938: DEBUG: MDB Creating message database
[CHATAPP] 11:35:31.952: DEBUG: MDB got 0 unopened messages
[CHATAPP] 11:35:31.952: DEBUG: SERV Message Notify new=0, unopened=0, force=true
[CHATAPP] 11:35:32.074: DEBUG: SERV Update Notification: serverError: true, lowerLayerUp: true, errorBits: 0x0, display: false
[CHATAPP] 11:35:32.075: DEBUG: SERV NotificationChange: icon -1->2130837534, message -1->0
[CHATAPP] 11:35:32.178: DEBUG: SERV Update Notification: serverError: true, lowerLayerUp: true, errorBits: 0x0, display: false
[CHATAPP] 11:35:32.231: DEBUG: SERV onStartCommand
[CHATAPP] 11:35:32.232: DEBUG: SERV startCore
[CHATAPP] 11:35:32.234: ERROR: SERV error reading config file: java.io.FileNotFoundException: /data/data/com.company.myApp/files/config.json: open failed: ENOENT (No such file or directory)
[CHATAPP] 11:35:32.235: DEBUG: SERV readConfig
[CHATAPP] 11:35:32.236: DEBUG: SERV config file does not exist
[CHATAPP] 11:35:32.238: DEBUG: SERV onBind
[CHATAPP] 11:35:32.246: DEBUG: CR ConnectivityReceiver: [WiFi(1)], connected:true, networkInfo: NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "WirelessA", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false
[CHATAPP] 11:35:32.251: DEBUG: CR ActiveNetwork: [WiFi(1)], connected:true, networkInfo: NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: "WirelessA", roaming: false, failover: false, isAvailable: true, isConnectedToProvisioningNetwork: false
[CHATAPP] 11:35:32.275: DEBUG: CR Network changed: type -1->1, subtype -1->0
[CHATAPP] 11:35:32.281: DEBUG: CR IP Address Change null->/fe80::40f3:8ff:fefd:f24d%p2p0%11
[CHATAPP] 11:35:32.283: WARN: SERV setNetworkType: type: 1, lastNetworkSpeedType: 1
[CHATAPP] 11:35:32.284: WARN: CM: Skip NetworkChangedEvent since IdleProc is unregistered or busy
[CHATAPP] 11:35:32.289: DEBUG: SERV ringerModeChange: 1, 0
[CHATAPP] 11:35:32.290: DEBUG: SERV setImplicitDnd: old=false, RM=1
[CHATAPP] 11:35:32.292: ERROR: SERV error reading config file: java.io.FileNotFoundException: /data/data/com.company.myApp/files/config.json: open failed: ENOENT (No such file or directory)
[CHATAPP] 11:35:32.293: DEBUG: SERV readConfig
[CHATAPP] 11:35:32.294: DEBUG: SERV config file does not exist
[DemoActivity] onPause: CONTACT
[BA] OnServiceConnected
[DemoActivity] CoreBoundListener onBind
[DemoActivity] init 42ae9d08
[CHATAPP] 11:35:32.362: DEBUG: SERV setListViewState: CONTACT