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
Highlighted
Developer
Posts: 37
Registered: ‎07-17-2008
My Device: Not Specified

Installation of multiple applications using the same library

Guys, one question. I have multiple applications that use the same library. I install this library and the application in the same jad. The problem is that, if I install one application that has that library and then I call another application's jad that also has the same library, it asks if I want to replace the previous library. If I say Yes, the application that I installed first does not work anymore.

 

The only solution right now is to install the library first and then install each application individually without the reference for the library in the Jad. But this makes the process harder for the users. Any ideas?

 

Thank you.

BlackBerry Development Advisor
Posts: 15,723
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Installation of multiple applications using the same library

Are all applications using the same version of the library?  Was it built in the same version of the BlackBerry JDE?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 37
Registered: ‎07-17-2008
My Device: Not Specified

Re: Installation of multiple applications using the same library

Hi Mark,

 

I have, for example, two different applications created in two different projects using the exact same library. And to answer your questions, it is the same version of the library and it was built in the same version of the JDE. Some users use only one application, others use many applications and when they install the library it says de module is already installed and it will be replaced. 

 

Thank you,

 Gustavo

BlackBerry Development Advisor
Posts: 15,723
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Installation of multiple applications using the same library

The prompt that the module is already installed and is overwritten is expected.

 

When you say your first application stops running, do you mean it is closed if running?  Or does it fail to run after this point?  If so, what error or exception do you see?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Installation of multiple applications using the same library

So what does the jad look like? I guess I could try that for my app but I thought it just put dependencies

in without any attempt to load missing libraries.

 

BlackBerry Development Advisor
Posts: 15,723
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Installation of multiple applications using the same library

Here is an example.  Note that if you have an auto-start application the library should be loaded first (listed as the first cod file) to ensure that the application does not fail to start the first time due to a missing dependency.

 

Manifest-Version: 1.0 RIM-COD-Module-Name: MyModule RIM-MIDlet-Position-1: 3 RIM-COD-Module-Dependencies: net_rim_cldc,MyLibrary MIDlet-Jar-Size: 40099 MIDlet-1: MyModule,, RIM-COD-Creation-Time: 1148412358 MIDlet-Jar-URL: MyModule.jar RIM-COD-URL: MyLibrary.cod RIM-COD-SHA1: 8f 3b b9 78 4d f3 72 44 f2 96 9f 95 56 b1 2a c8 d6 e4 1f e2 RIM-COD-Size: 22684 MicroEdition-Configuration: CLDC-1.1 RIM-MIDlet-Position-1: 3 RIM-COD-Module-Name-1: MyModule.cod RIM-COD-URL-1: MyLibrary.cod RIM-COD-Size-1: 27044 RIM-COD-SHA1-1: 46 7d 66 db d6 b9 53 c9 30 1e cd 2e 18 86 dc b3 10 d7 20 e6 MIDlet-Version: 1.16 MIDlet-Name: MyModule MIDlet-Vendor: Me MicroEdition-Profile: MIDP-2.0 RIM-MIDlet-Flags-1: 0

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Installation of multiple applications using the same library

I have been running into the same problem now. I have a shared libray common.cod and two apps: A.cod and B.cod. As soon as I add a reference of common.cod to both the JADs of A and B and then attempt to install both apps, the secondly installed up will delete the first installed up because the installation routine complains about that module common.cod is already defined in app A and B will replace that.

 

The only way to get around this problem at the moment is to download common.cod via its own jad file and have it references as a dependency only by A and B. However, this isn't very user friendly in terms of initial installation and in terms of future updates. You cannot expect the user to always download two files for one application.

 

Has anybody come up with solution or a work around to this disappointing limitation?

 

It all wouldn't be a problem if like on other mobile platforms, you could include the same classes with each application and the each application would be executed in its own little sandbox so that there wouldn't be any 'multiply defined classes' errors. Using classloaders in the right way would solve this problem!

 

 

New Developer
Posts: 9
Registered: ‎03-05-2009
My Device: Not Specified

Re: Installation of multiple applications using the same library

I faced the same problem and the solution that I had then wasn't good, but had to come up with something... two products were waiting for release.

 

What I did was, I added the libraries/classes to both the applciation but with a differnt package name

 

com.company.rim.product1.[ui/data/io/]

com.company.rim.product2.[ui/data/io/]

 

Here my data package was same for both the products.

 

If you have come up with a better solution by now... please let me know.

 

Thank you.

Developer
Posts: 242
Registered: ‎01-29-2009
My Device: Not Specified

Re: Installation of multiple applications using the same library

I ended up with the same. I keep my commons library in a separate project in Eclipse etc. However, during my build process with Ant (where I also use the great bb-ant tools) I will copy the commons classes to a sub-package 'commons' within my apps' package structure, so that all the classes have different names. I  then run a quick 'replace' task on all Java files to change the package references before compiling everything.

 

In the end I actually think this works quite well since it will allow me to release updates to one app with new common classes withtout having to release the other app(s) at the same time too. Give me more flexibility and isolation and thanks to the automated build, I don't have to manually copy classes and or keep copies up-to-date.