I'm working on games and would like my games to share library code.
In this case I have some geometry calculations and some common UI
helper functions.  But my question is more generic than just that.  I
would like to know how to create a library of code that I would reuse
in various games.  Maybe I just don't understand Java or maybe this is
a Android question.  As I mentioned I'm a C++ programmer, so I'm very
used to that programming model.

If this were C++, I would place the library code in a different folder
structure.  I would then have options on how to link that code.  I
could compile it into a library file.  I could also have my
environment include a copy of the source and compile it directly as if
it was part of the application.  Both methods work equally well and
have their pros and cons which are beyond the scope of this group.

This is extremely simple in C++, but in Java/Android it's not clear.
You can easily try what I did to see what's wrong.  Even if what I'm
doing is wrong (which would not surprise me), I've discourage by the
lack of any message and a crash when doing something that up until
that point seems reasonable.  In C++ if you can get past the compiler
and linker messages, it works.  In Java/Android, this confirmation
that all is good seems to be missing.

To recreate what I did, simply use the Eclipse wizard to create a new
Android Application.  Run it and get the Hello App text on the
screen.

Then create a new project, however tell the Wizard to not create an
Android Activity (uncheck the checkbox).  Then add a class and a
public static method and call it inside your Android onCreate code
from the first project .  The system will simply stop working without
a helpful message as to what's wrong, but will build cleanly.

If anyone knows how to create a library I could reuse in various
programs, I would appreciate it.  Is this question a Java or Android
question?

Thanks,

Mitch

On Mar 1, 6:59 am, Dori <[email protected]> wrote:
> What exactly are you trying to do here?
>
> Do you just want an activity to call a method from another class you
> have written or do you want to be able to import a library contained
> in a .jar file?
>
> Dori
>
> On Mar 1, 5:24 am, Mitch <[email protected]> wrote:
>
>
>
> > I'm using Eclipse.  I created a new Android Project with the wizard
> > and I can start the application in the emulator.  I would like to
> > create a class outside of the project (like it would be in a library)
> > and call it.  I created another Android Project without an Activity
> > name and created a class with a "public static" method.  All compiles,
> > but it won't run.  It just crashes without any helpful information.
>
> > Since there is no code inside my method, something else must be
> > wrong.  I assume I don't understand something about how things link in
> > Java/Android (C++ programmer here).  Can anyone explain or show me a
> > tutorial on how to create a class in a library so I can call it from
> > my project?  Should I be creating a Android Project or something
> > else?
>
> > Thanks,
>
> > Mitch- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to