Thursday, December 13, 2012

[android-developers] Re: How to access a AIDL service from different packages?

Hi Priyank,

Problem belong this step:
>I have exported this in the source code of the application as
>import com.VMService;

you don't need to do this step because because aidl generate Java interface, refer: http://developer.android.com/tools/building/index.html

i guest your error come because class com.VMService not available during runtime,
although in compile and packaging time is OK because it using difference class
(I not sure about order in compile time and runtime)

Best Regards,

On Wednesday, June 30, 2010 11:46:56 PM UTC+5:30, Priyank wrote:
Hi,
I am kind of facing a similar problem with my project.
I have an existing project which has 2 parts. Services module and
Application module.
The VMService.aidl file is in a package in the services. When the
service module is compiled, the generated VMService.java file appears
in the /gen folder.

I have exported this in the source code of the application as
import com.VMService;

But I am still getting run time errors during the launch of the
application.
The LogCat logs show this:
Could not find class com.VMService
06-30 17:33:11.248: ERROR/dalvikvm(460): Could not find class
'com.VVMService', referenced from method
com.samsung.vvmapp.VMApplication.onActivityResult

06-30 17:33:11.457: ERROR/AndroidRuntime(460):
java.lang.NoClassDefFoundError: com.VMService

Please let me know what wrong I am doing.
Thanks,
Priyank

On Jun 24, 10:25 am, Krishna Shetty <krishna.shett...@gmail.com>
wrote:
> It became clear now. Thank you Mark.
> The problem was, I am having my AIDL interface in a different package.
> And I have included the same AIDL interface package in both Service
> and Client application. But  the   <intent-filter>  of the Service had
> <action> string with package name of the Service.
>
> So we can follow below while adding <intent-filter>, so trhat trick
> "IScript.class.getName()" will work.
>
> <service android:name=".serviceName" android:exported="true"
> android:enabled="true">
> <intent-filter>
> <action android:name="package name of aidl interface.Interface name" /
>
> </intent-filter>
> </service>
>
> thanks,
> Krishna
>
> On Jun 23, 7:02 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
>
>
> > On Wed, Jun 23, 2010 at 9:57 AM, Krishna Shetty
>
> > <krishna.shett...@gmail.com> wrote:
> > > Thank you very much Mark, Joe.
>
> > > But below call i.e., binding with the Interface name is not working. I
> > > got the same error, "not able to bind, service not found.."
> > > bindService(new Intent(IScript.class.getName()), svcConn,
> > > Context.BIND_AUTO_CREATE);
>
> > That means you have no service with an <intent-filter> containing an
> > <action> string that matches the value generated by
> > IScript.class.getName(). If you are taking that code from one of my
> > samples, the corresponding manifest from those samples is set up
> > properly:
>
> >http://github.com/commonsguy/cw-advandroid/tree/master/AdvServices/Re...
>
> > > But, below way of binding works. i.e., Binding with the exported
> > > Service.
> > > Intent i = new Intent();
> > > i.setClassName("com.mt.TestRemoteService",
> > > "com.mt.TestRemoteService.MyService");
> > > bindService(i, svcConn, Context.BIND_AUTO_CREATE);
>
> > This is extremely fragile. If the other application refactors its
> > code, your code will break.
>
> > > Why bind with Interface name is not working for me?
> > > ( Note: I have added an <intent-filter> on the <service> with a
> > > Interface <action> )
>
> > Whatever you think you did, it is not working.
>
> > Rather than use my IScript.class.getName() trick, it is probably
> > simpler for you to just use the literal string. Copy whatever string
> > is in your <action> and paste it as a string literal in your Intent
> > constructor.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.6
> > Available!- Hide quoted text -
>
> - Show quoted text -

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment