*- I've made the jar approach work before, and intuitively statically 
linked code shouldn't really be doing anything as long as you're not 
making references to the resources classes. 
*
I was hoping someone would say this.  Thankyou.  I will try to paste the 
code I was trying in a while and then hopefully you could identify any 
changes. And yes I'm certainly not using resources.

*- Why do you think you have to distribute code with an Android library 
project?  You can just remove (everything in) the src/ directory and 
distribute it that way, no source required. 
*

- Now given that you have got the jar approach to work, I will hold on to 
the Android Library approach for the moment. 



On Wednesday, February 13, 2013 5:33:30 PM UTC-8, Kristopher Micinski wrote:
>
> I'm still confused for two reasons: 
>
> - I've made the jar approach work before, and intuitively statically 
> linked code shouldn't really be doing anything as long as you're not 
> making references to the resources classes. 
>
> - Why do you think you have to distribute code with an Android library 
> project?  You can just remove (everything in) the src/ directory and 
> distribute it that way, no source required. 
>
> I'm not sure why your previous approach wasn't working: I'd have to 
> see an example of what you're doing to postulate as to why you 
> couldn't make it work, but in the end everything is bytecode. 
>
> Kris 
>
> On Wed, Feb 13, 2013 at 8:25 PM, RKSHR <[email protected] <javascript:>> 
> wrote: 
> > The discussion that I started initially was to find out if a service can 
> be 
> > defined in a jar file (not Android library) and if the jar file can be 
> > distributed for application developers and if they can bind or start 
> that 
> > service ?  I was simply unable to do it.  Ofcourse, the service was 
> declared 
> > in the application's manifest file.  Once I created a Android library 
> and 
> > defined the service in the library, then it worked fine, but with this 
> > approach, source code of the library will have to distributed. 
> > 
> > RK 
> > 
> > 
> > On Wednesday, February 13, 2013 4:26:51 PM UTC-8, Kristopher Micinski 
> wrote: 
> >> 
> >> If I'm not misreading this discussion, the problem is that every 
> >> service must explicitly be declared in a manifest file.  There is no 
> >> such thing as implicitly or programmatically creating a service. 
> >> (This has an unfortunate benefit for would be dynamic scripting 
> >> languages implemented ala JVM wrapper which might otherwise allow you 
> >> to have first class components..) 
> >> 
> >> This is pretty typical: lots of jars for Android are distributed with 
> >> the caveat that you need to explicitly declare a certain Service in 
> >> your Android manifest. 
> >> 
> >> And yes, library projects basically allow you to do this for the user 
> >> using your project, so that they don't have to (as) explicitly set up 
> >> your components. 
> >> 
> >> Kris 
> >> 
> >> On Wed, Feb 13, 2013 at 5:11 PM, RKSHR <[email protected]> wrote: 
> >> > I spent some more time and this is what I found so far. 
> >> > 
> >> > - An app cannot bind to a service or instantiate a service if the 
> >> > service is 
> >> > declared in a jar file (that is not a Android library).  Note that 
> I'm 
> >> > just 
> >> > building a jar file using javac compiler and jar utility, without the 
> >> > need 
> >> > for AndroidManifest xml file. I tried creating a TestService class 
> that 
> >> > extends Service class and built that into a jar.  In a test app, I 
> >> > imported 
> >> > the jar file and put a break point in onStart() and onCreate() 
> methods 
> >> > of 
> >> > TestService class.  In the app I tried calling both bindService and 
> >> > startService, both of them return a false or a null value and the 
> >> > debugger 
> >> > never breaks in onStart() or onCreate().  Both these methods had one 
> >> > line 
> >> > implementations with a just a call to their super class like 
> >> > super.onStart(). 
> >> > 
> >> > - In the next step I moved the TestService outside of the jar into an 
> >> > Android library (in Eclipse enable checkbox "Is Library" or 
> >> > project.properties should contain android.Library=true ).  I built 
> the 
> >> > library and included it into the test app. Now i can instantiate the 
> >> > service 
> >> > using bindService API from the app, the debugger breaks in onStart() 
> and 
> >> > onCreate()  methods of TestService class. 
> >> > 
> >> > 
> >> > On Monday, February 11, 2013 4:30:56 PM UTC-8, Lew wrote: 
> >> >> 
> >> >> RKSHR wrote: 
> >> >>> 
> >> >>> No the JAR is not set up as a Library project, as all I have is, 
> >> >>> compile 
> >> >>> the classes using javac and then bundle them into a jar using jar 
> >> >>> builder. 
> >> >> 
> >> >> 
> >> >> You should probably build it as a library project, since it does 
> have 
> >> >> something specific to Android in it. 
> >> >> 
> >> >> I'm not expert in library projects, but as I understand they're the 
> way 
> >> >> to 
> >> >> package Android stuff for other Android stuff. 
> >> >> 
> >> >> 
> >> >> By "nothing specific to android [sic]", I meant the classes used 
> within 
> >> >> the service, other than the obvious service class.  I did not have 
> this 
> >> >> service class before and there is a singleton factory class that the 
> >> >> app was 
> >> >> using to instantiate.  Now I have moved the factory instantiation 
> into 
> >> >> the 
> >> >> service class. I want the app to just bind to the service, so the 
> >> >> factory 
> >> >> instantiation happens in the background within the service. 
> >> >> 
> >> >> 
> >> >> There's a world of difference between "nothing" and "nothing other 
> >> >> than... 
> >> >> ". 
> >> >> 
> >> >> And that difference might be the difference that makes the 
> difference. 
> >> >> You 
> >> >> might want to investigate. 
> >> >> 
> >> >>> 
> >> >>> Lew wrote: 
> >> >>>> 
> >> >>>> RKSHR wrote: 
> >> >>>>> 
> >> >>>>> I did make sure that there were no R.xx classes in the service, 
> >> >>>>> infact 
> >> >>>>> I dont need any resources in the service.  I did double check 
> again 
> >> >>>>> and 
> >> >>>>> nothing was present, although an import definition to resources 
> >> >>>>> class was 
> >> >>>>> left there.  I wasn't sure if it would make a difference, but I 
> >> >>>>> removed that 
> >> >>>>> definition anyway and recompiled the jar without any different 
> >> >>>>> result.  The 
> >> >>>>> application loading the jar, still cannot bind to the service. 
> The 
> >> >>>>> service 
> >> >>>>> is a very simple class that just instantiates a set of regular 
> java 
> >> >>>>> classes 
> >> >>>>> (nothing specific to Android).  I'm not even able to debug into 
> the 
> >> >>>>> service, 
> >> >>>>> I have a break point at onStart() and onCreate() methods and it 
> >> >>>>> never falls 
> >> >>>>> there. I will continue looking. .thanks. 
> >> >>>> 
> >> >>>> 
> >> >>>> "nothing specific to Android" is obviously false since there's a 
> >> >>>> service 
> >> >>>> class in there. 
> >> >>>> 
> >> >>>> Is the JAR source set up as an Android library project? 
> >> >>>> 
> >> >> 
> >> > 
> >> > -- 
> >> > -- 
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Android Developers" group. 
> >> > To post to this group, send email to [email protected] 
> >> > To unsubscribe from this group, send email to 
> >> > [email protected] <javascript:> 
> >> > For more options, visit this group at 
> >> > http://groups.google.com/group/android-developers?hl=en 
> >> > --- 
> >> > You received this message because you are subscribed to the Google 
> >> > Groups 
> >> > "Android Developers" group. 
> >> > To unsubscribe from this group and stop receiving emails from it, 
> send 
> >> > an 
> >> > email to [email protected]<javascript:>. 
>
> >> > For more options, visit https://groups.google.com/groups/opt_out. 
> >> > 
> >> > 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Android Developers" group. 
> > To post to this group, send email to 
> > [email protected]<javascript:> 
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:> 
> > For more options, visit this group at 
> > http://groups.google.com/group/android-developers?hl=en 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Android Developers" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to