android aidl服务与Binder invocat…

来源:互联网 发布:java日志级别大小 编辑:程序博客网 时间:2024/05/21 17:59

androidaidl服务用于不同客户端来调用,一般是先安装服务(服务没有应用Activity),再安装其他客户端,调用时客户端需定义与aidl服务相同的包名的aidl文件。否则会出现接口找不到,服务无法初始化的问题.而导致Binderinvocation to an incorrect interface的异常。

 

我做了一个调用谷歌翻译api的客户端。应用的就是此原理。自定义aidl文件,但在使用过程中报如下错误:
02-27 11:42:19.994: WARN/Parcel(31504): **** enforceInterface()expected 'com.google.android.apps.translate.ITranslate' butread

'com.cjq.translator.ITranslate'

02-27 10:16:34.767: ERROR/Translator(30196): Error: Binderinvocation to an incorrect interface

从错误分析得知:我们自定义的aidl文件须与调用的谷歌翻译api的包名不一致,可能是导致 invocation to anincorrect interface的原因。
因此我将aidl文件和服务的包名更改后,再进行调试。问题解决.同时注意AndroidManifest文件也应有相应定义.

0 0