Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 34
Registered: ‎03-14-2010
My Device: N/A
My Carrier: Fledge

Best way to share a library between apps?

I have a set of classes which I would like to reuse in many projects.  

 

In the past, I have created a library that I reference in multiple projects. But how can I facilitate the distribution of said library with OTA installation and through the BB App World?

 

Thanks!

Developer
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: Best way to share a library between apps?

You can package it as a background app and it listens to a global event. Upon receiving a predefine event, you create an instance of an object and send it back to the requestor.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Best way to share a library between apps?

You ask a very good question and one to which there is not a perfect answer.  However RIM are aware of the issue of library cods - we had a round table discussion about them at the last DevCon.

 

At present, as far as I know, the only way to do this effectively and to make it possible to maintain the library and the applications as separate entities is to package them as completely separate 'downloads'.  So OTA, you have a library OTA install, then the application(s), for App World, you need to do the same.

Highlighted
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Best way to share a library between apps?

I agree with Aviator's solution.

 

It's the only working solution currently.

 

Unfortunately you cannot set dependency that way (- consequence: cannot use strongly typed class) , but you cannot do that (completely)  for peter's suggestion neither. (OK, if you can live with that "library file missing" error and burdening the user by asking for an additional download ! -> absolutely terrible solution I must add)

 

Just try it out: install app1 with lib1. OTA provision it. install app2 with lib1. OTA provision it.

 

AFAIR the app1 will be mysteriously removed Smiley Sad

 

Then try to provision just the lib1.1 (lib1 with an update) again, the last associated application will be removed.

 

But alas that completely misses the point of independent library development/provisioning.

 

 



"Listen carefully, I shall say this only once"
Contributor
Posts: 34
Registered: ‎03-14-2010
My Device: N/A
My Carrier: Fledge

Re: Best way to share a library between apps?

Thank you for all of your suggestions amd thoughts.  Aviator, could you go into a bit more detail as to how this is possible?  

 

I understand the concept of retrieving the object from a background application but I am not sure how the background library would be installed and maintained.

Developer
Posts: 16,985
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Best way to share a library between apps?

We install ksoap as a separate library and have installed several products on one device without any of them getting removed.

alx/jad refer to two cod files, the application file and the library file.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Best way to share a library between apps?

I must admit that I did not understand how Avaitor168's response was actually a solution to the question asked.  Yes, you can have some loose interaction and have the process return a random Object, but how will the invoking application actually know what to do with that Object?

 

Similarly, I do not completely understand myraddin's post. 

 

I agree with Simon.  The most workable solution at the moment is to have the library in a separate package.  It is not perfect,  The problem is highlighted by myraddin's comment

 

"OK, if you can live with that "library file missing" error and burdening the user by asking for an additional download ! -> absolutely terrible solution I must add"

 

However I think a 'library is missing error' once, at installation time, is better than a delete of one application causing other applications to fail and is small price to pay for being able directly use the

Library from your application.

 

Installation is a one-off event, with good documentation is having to do two downloads a big deal?

 

But that is just my opinion.

Developer
Posts: 16,985
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Best way to share a library between apps?

but why two downloads? if i manually add the library cod to the main application jad file (or alx file) the library is installed, but i don't experience the problem of an app no longer working when i delete the other.

 

i just tested it on my phone. installed are app A and B, both have ksoap2 as a library, installed as a separate cod.

both are running fine. i uninstall A, reboot the phone. B is still working and still has ksoap2 listed as a module.

 

the process is transparent to the user, no interaction required.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Best way to share a library between apps?

Thanks for trying that Simon. 

 

I had found in the past that this did not always work as I would have expected. 

 

To describe what I tested, assume you have two applications with one shared library.  Call the applications A and B, and the shared library Z.  To install these OTA, I created two jads, Jad 1 with A & Z, and jad 2 with B & Z.  I installed jad 1 and then jad 2, then deleted the application installed with jad 1.  I got different results on different devices as follows:

a)  On some devices installing jad 2 removed jad 1

b) On some devices deleting jad 1 removed the library and so jad 2 stopped working

c) On some devices it worked as expected.

 

This testing was a while ago, from memory at the time I did the test the most current OS I had was an early 4.6 device, so it was probablyabout 18 months ago.  So I should run the test again. 

 

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Best way to share a library between apps?

Simon, can you confirm that this is the scenario:

 

1) OTA provision A + ksoap2. (single .jad file provisioning)

2) OTA provtions B + ksoap2. (again, single .jad file provisioning)

 

Q:

3) You can now separately OTA provision another (let's say updated) ksoap2 ?

4) You can uninstall either App A or B and the other one is untouched ?

5) You can uninstall ksoap2 and running A and/or B just reports: "library missing" ?

 

 

3), 4) and 5) all answered YES should be the proper library handling. 

 

I am curiously awaiting for your reply.

 

 

 

 



"Listen carefully, I shall say this only once"