How to integrate 3rd party Android library with MIDlet code?

28 views
Skip to first unread message

Bartek Teodorczyk

unread,
Nov 24, 2009, 11:47:14 AM11/24/09
to microemulator-support
I've got that question recently and I think it is worth to show the
solution for wider audience.

When using Ant script from microemu-android/build.xml the following
modifications are necessary:
1. If MIDlet contains references to the 3rd party Android library
"compile" target has to know the location of library jar. Add new
pathelement pointing to the Android library: <pathelement location="$
{library.jar}"/>
2. Add new arg to the "dex" target (full path is needed): <arg value="$
{full-path-library.jar}"/>

BR,
Bartek Teodorczyk

Tomas Kaminskas

unread,
Nov 25, 2009, 8:25:17 AM11/25/09
to microemulator-support
Bartek,

thanks for the help, I have managed to compile my project with a call
to a 3rd party jar library, but the call was in MicroEmulator class.
As I do understand, MicroEmulator includes jar file and recompiles it
for Android, but I can't make a call to a 3rd party jar library at
MIDlet, as I will need to compile and build it with some j2me tool
(for example WTK), and it won't compile as it will have some
unrecognizable calls for Android classes?
I am not sure everybody will understand what I have tried to explain,
but my idea was that this solution lets to add call to 3rd party
library from Android file, but not from MIDlet. What would be the way
to be able to call Android method from MIDlet?

Best regards,
Tomas Kaminskas

Bartek Teodorczyk

unread,
Nov 26, 2009, 7:10:11 AM11/26/09
to microemula...@googlegroups.com
Tomas,

You should change your build script not to use WTK when building
MIDlet. This is fairly easy with the combination of Ant, Proguard and
MicroEmulator.

BR,
Bartek Teodorczyk
> --
>
> You received this message because you are subscribed to the Google Groups "microemulator-support" group.
> To post to this group, send email to microemula...@googlegroups.com.
> To unsubscribe from this group, send email to microemulator-su...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/microemulator-support?hl=en.
>
>
>

Tomas Kaminskas

unread,
Nov 26, 2009, 8:56:18 AM11/26/09
to microemula...@googlegroups.com
Hi Bartek,
 
could you give a more detailed instruction on how do you build MIlet's using Ant, Proguard and MicroEmulator, something similar like instructions for running Midlets on Android, I never used this approach, also maybe this would be usefull for someone in the future?
 
Best regards,
Tomas Kaminskas

2009/11/26 Bartek Teodorczyk <bar...@gmail.com>

Bartek Teodorczyk

unread,
Nov 26, 2009, 10:23:39 AM11/26/09
to microemula...@googlegroups.com
Tomas,

I'm attaching sample build script, you have to modify paths in the
following places:

<property name="microemulator"
value="/Users/barteo/Desktop/Java/microemulator" />
<taskdef resource="antenna.properties"
classpath="lib/antenna-bin-1.0.2.jar"/>
<taskdef resource="proguard/ant/task.properties"
classpath="lib/proguard.jar" />

also paths inside the proguard task.

BR,
Bartek Teodorczyk

On Thu, Nov 26, 2009 at 2:56 PM, Tomas Kaminskas
build.xml

Tomas Kaminskas

unread,
Nov 29, 2009, 2:27:42 PM11/29/09
to microemulator-support
Hi Bartek,

thanks for the help. I have built the midlet with your build file, and
have integrated 3rd party jar file into the midlet. Now I have faced
another problem, I have to call a method from that library: initialize
(this.getApplicationContext(), "id");
Of course midlet doesn't understand's what is getApplicationContext as
this is a method from Android, is it possible to get Android's "this"
in the midlet?

Best regards,
Tomas Kaminskas
>  build.xml
> 2KViewDownload- Hide quoted text -
>
> - Show quoted text -

Bartek Teodorczyk

unread,
Nov 30, 2009, 10:01:44 AM11/30/09
to microemula...@googlegroups.com
Tomas,

Could you explain you problem more descriptive?

BR,
Bartek Teodorczyk

Tomas Kaminskas

unread,
Nov 30, 2009, 11:24:15 AM11/30/09
to microemula...@googlegroups.com
Hi Bartek,
 
I am trying to convert midlet into Android package, also to add 3rd party Android advertising library (Greystripe). What I am doing, I am compiling midlet with Greystripes library included, and from that library I am calling method -

public static GSSDK initialize(Context ctx, String appId)

As described in Greystripes documentation -

To initialize the Greystripe SDK, call the initialize method at startup. This should be done within your application’s onResume() method. This call will spawn a background thread to complete initialization and then return control to your app. In the background thread, the Greystripe client will download ads as well as any SDK updates.

Parameters:

ctx

: Your application Context instance

appId

: During testing, use the provided Test App ID which will allows you to test your SDK implementation with a variety of ad types. When creating your production build, use the provided Production App ID and verify that you correctly receive ads. Providing an invalid appId will cause the SDK to display error notification ads.
So my problem is that midlet doesn't know anything about Android's Context, how can I get a link to that?
 
Best regards,
Tomas Kaminskas
2009/11/30 Bartek Teodorczyk <bar...@gmail.com>

Adrian Vintu

unread,
Nov 30, 2009, 11:54:01 AM11/30/09
to microemulator-support
I guess you can add the code in the MicroEmulator.java

The override of the onResume is already present there.

BR,
Adrian Vintu

On Nov 30, 5:24 pm, Tomas Kaminskas <kaminskas.to...@gmail.com> wrote:
> Hi Bartek,
>
> I am trying to convert midlet into Android package, also to add 3rd party
> Android advertising library (Greystripe). What I am doing, I am compiling
> midlet with Greystripes library included, and from that library I am calling
> method -
>
> *
>
> public static GSSDK initialize(Context ctx, String appId) *
> > >> >> > To unsubscribe from this group, send email to> >> >> >microemulator-su...@googlegroups.com<microemulator-support%2Bunsu...@googlegroups.com>
> > .
> > >> >> > For more options, visit this group at
> > >> >> >http://groups.google.com/group/microemulator-support?hl=en.
>
> > >> >> --
>
> > >> >> You received this message because you are subscribed to the Google
> > Groups
> > >> >> "microemulator-support" group.
> > >> >> To post to this group, send email to> >> >>microemula...@googlegroups.com.
> > >> >> To unsubscribe from this group, send email to> >> >>microemulator-su...@googlegroups.com<microemulator-support%2Bunsu...@googlegroups.com>
> > .
> > >> >> For more options, visit this group at
> > >> >>http://groups.google.com/group/microemulator-support?hl=en.
>
> > >> > --
>
> > >> > You received this message because you are subscribed to the Google
> > Groups
> > >> > "microemulator-support" group.
> > >> > To post to this group, send email to>microemula...@googlegroups.com.
> > >> > To unsubscribe from this group, send email to> >> >microemulator-su...@googlegroups.com<microemulator-support%2Bunsu...@googlegroups.com>
> > .
> > >> > For more options, visit this group at
> > >> >http://groups.google.com/group/microemulator-support?hl=en.
>
> > >>  build.xml
> > >> 2KViewDownload- Hide quoted text -
>
> > >> - Show quoted text -
>
> > > --
>
> > > You received this message because you are subscribed to the Google Groups
> > "microemulator-support" group.
> > > To post to this group, send email to>microemula...@googlegroups.com.
> > > To unsubscribe from this group, send email to>microemulator-su...@googlegroups.com<microemulator-support%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/microemulator-support?hl=en.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "microemulator-support" group.
> > To post to this group, send email to>microemula...@googlegroups.com.
> > To unsubscribe from this group, send email to>microemulator-su...@googlegroups.com<microemulator-support%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages