Re: [android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-14 Thread RKSHR

*- 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 rks...@gmail.com 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 rks...@gmail.com 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 

Re: [android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-14 Thread Kristopher Micinski
Sure,

Although at the same time, if you are doing this, you really *should*
be using an Android library project: it just makes it simpler for the
users of the library.

kris

On Thu, Feb 14, 2013 at 12:32 PM, RKSHR rksh...@gmail.com wrote:

 - 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 rks...@gmail.com 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 rks...@gmail.com 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 

[android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-13 Thread RKSHR
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-13 Thread Kristopher Micinski
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 rksh...@gmail.com 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 android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 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 android-developers+unsubscr...@googlegroups.com.
 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at

Re: [android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-13 Thread RKSHR
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 rks...@gmail.com javascript: 
 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 
  

Re: [android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-13 Thread Kristopher Micinski
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 rksh...@gmail.com 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 rks...@gmail.com 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
  

Re: [android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-13 Thread Kristopher Micinski
I should have said, statically linked code isn't really doing
anything *differently*

Kris

On Wed, Feb 13, 2013 at 8:33 PM, Kristopher Micinski
krismicin...@gmail.com 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 rksh...@gmail.com 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 rks...@gmail.com 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 

[android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-11 Thread Streets Of Boston
Maybe this service class uses/loads other classes that fail to load.

Strong candidates that may fail to load are R. classes and their 
members: If your JAR is generatedfrom a library project and if you 
distribute just the JAR file, you may not distribute any R. classes 
along with it, since these are not included in the JAR generation of a 
library project. 

On Monday, February 11, 2013 2:57:54 PM UTC-5, RKSHR wrote:

 I have an external jar file that we have been using to import into an 
 application apk.  Recently I added a Android service class into the jar 
 file, now when I import the file into an apk, I can instantiate all classes 
 except the service. I have declared the service in the applications 
 manifest file (with fully qualified class path), but when I try to bind to 
 the service using context.bindService(intent, connection, 
 BIND_AUTO_CREATE), nothing happens.  I dont get any exception, nor an error 
 message, but service is not instantiated, as the return value for 
 bindService is false.

 I examined the contents of jar file to make sure that the service class is 
 actually included.  I also further dedexd the application dex file and even 
 there the library service class was present. Any ideas what could be the 
 problem? I have read several posts on this, but still unable to figure out 
 the problem.  What I really want to achieve is provide a Android service 
 class in a library (jar file), so application developers can simply bind to 
 the service and it starts the run within the context of the application.  I 
 don't want the service to be remote, hence not using AIDL.  Also the jar is 
 built using ant build.xml, its not marked as a library project, but just as 
 a regular jar file that can be imported into any application.  The goal is 
 to distribute the jar file without the source code, hence not marking it as 
 library.

 RK.



-- 
-- 
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+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-11 Thread RKSHR
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.


On Monday, February 11, 2013 12:12:17 PM UTC-8, Streets Of Boston wrote:

 Maybe this service class uses/loads other classes that fail to load.

 Strong candidates that may fail to load are R. classes and their 
 members: If your JAR is generatedfrom a library project and if you 
 distribute just the JAR file, you may not distribute any R. classes 
 along with it, since these are not included in the JAR generation of a 
 library project. 

 On Monday, February 11, 2013 2:57:54 PM UTC-5, RKSHR wrote:

 I have an external jar file that we have been using to import into an 
 application apk.  Recently I added a Android service class into the jar 
 file, now when I import the file into an apk, I can instantiate all classes 
 except the service. I have declared the service in the applications 
 manifest file (with fully qualified class path), but when I try to bind to 
 the service using context.bindService(intent, connection, 
 BIND_AUTO_CREATE), nothing happens.  I dont get any exception, nor an error 
 message, but service is not instantiated, as the return value for 
 bindService is false.

 I examined the contents of jar file to make sure that the service class 
 is actually included.  I also further dedexd the application dex file and 
 even there the library service class was present. Any ideas what could be 
 the problem? I have read several posts on this, but still unable to figure 
 out the problem.  What I really want to achieve is provide a Android 
 service class in a library (jar file), so application developers can simply 
 bind to the service and it starts the run within the context of the 
 application.  I don't want the service to be remote, hence not using AIDL. 
  Also the jar is built using ant build.xml, its not marked as a library 
 project, but just as a regular jar file that can be imported into any 
 application.  The goal is to distribute the jar file without the source 
 code, hence not marking it as library.

 RK.



-- 
-- 
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+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-11 Thread Lew
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?

-- 
Lew

-- 
-- 
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+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-11 Thread RKSHR
Lew,
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. 

By nothing specific to android, 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.

RK

On Monday, February 11, 2013 2:02:43 PM UTC-8, 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?

 -- 
 Lew



-- 
-- 
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+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Binding to Android service in an external jar doesn't seem to be working

2013-02-11 Thread Lew
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.