Question

I am working on AIDL. My .aidl file is in another project(another application). Suppose the aidl file name is IService.aidl. But I get this error(shown below) on onServiceConnected(ComponentName componentName, IBinder iBinder) method while assigning

IService service = IService.Stub.asInterface((IBinder)iBinder);

1.What can be the problem?
2.Also how to access IService(aidl) of another project?

03-03 13:11:42.184: E/AndroidRuntime(2558): FATAL EXCEPTION: main
03-03 13:11:42.184: E/AndroidRuntime(2558): java.lang.NoClassDefFoundError: aexp.aidl.IService$Stub
03-03 13:11:42.184: E/AndroidRuntime(2558):     at com.test.aidlclient.AIDLClientDemoActivity$AdditionServiceConnection.onServiceConnected(AIDLClientDemoActivity.java:72)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at android.app.ActivityThread$PackageInfo$ServiceDispatcher.doConnected(ActivityThread.java:1247)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at android.app.ActivityThread$PackageInfo$ServiceDispatcher$RunConnection.run(ActivityThread.java:1264)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at android.os.Handler.handleCallback(Handler.java:587)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at android.os.Looper.loop(Looper.java:123)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at java.lang.reflect.Method.invokeNative(Native Method)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at java.lang.reflect.Method.invoke(Method.java:521)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-03 13:11:42.184: E/AndroidRuntime(2558):     at dalvik.system.NativeStart.main(Native Method)
Was it helpful?

Solution

You have to copy aidl file to your current project. Then you have to check if java class was generated for this aidl file. I think that you did not include aidl file in your current client. If this did not help you try to clean your client project.

OTHER TIPS

The RemoteInterface.aidl needs to have the same package name in both the service and the application that needs to connect to the service - so the question is : where do you put it!?

If you are developing in Eclipse then the trick is to have a common source folder (common to both projects) Make this folder outside of both projects and in the build properties/source, click 'link source' and browse to the location of the common source. (You can call it any name you want) Do this in both projects and put the interface.aidl in there. It will appear in both projects' Package Explorer and when you change it in one project, the other will get updated too.

In the common source folder put the interface.aidl in a package with the same name as the service.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top