Trouble using android.jar in applications through eclipse

604 views
Skip to first unread message

lr

unread,
Apr 26, 2011, 5:32:25 PM4/26/11
to android-platform
Hi,

I am trying to use the custom built android.jar to build an
application in place of the one that ships with the SDK. I downloaded
the froyo source code and did the following

1) source build/envsetup.sh
2) lunch 1
3) make
4) make update-api
5) make sdk

I copied the file in $froyo_home/out/host/linux-x86/sdk/android-
sdk_eng.kctg86_local_linux-x86/platforms/android-2.2.1/android.jar

I added it in my build path in eclipse and removed the already present
JAR file. I use the downloaded SDK at API level 8 for froyo.

I wrote a simple home application and it does not work with the new
android.jar. I get this error

Dx
trouble processing "javax/security/auth/Subject.class":

Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.

This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.

However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.

If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.

If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.

If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
[2011-04-26 16:46:44 TestApp1] Dx 1 error; aborting
[2011-04-26 16:46:44 TestApp1] Conversion to Dalvik format failed with
error

This only happens with the android.jar built by downloading the source
code. It goes away if I use the android.jar that ships with the SDK.
Most of the forums told me to do a project clean and rebuild and they
never worked. If anyone has faced this issue and figured it out,
please let me know

Thanks
lav

David Herges

unread,
Sep 23, 2011, 12:01:11 PM9/23/11
to android-...@googlegroups.com
I ran into the same problem and I figured out:

1) Customise your android platform and make
2) make sdk
3) It creates a sdk directory in out/host/linux-x86/sdk/android-sdk_eng.USERNAME_linux-x86/
4) Copy that directory somewhere, e.g. "/etc/android-sdk-custom"
5) In Eclipse: Preferences > Android, select SDK Location and point to "/etc/android-sdk-custom", Click Apply
6) You can now create an Android application that is linked against your customised Android Platform


Cheers,
David

ruchita rathi

unread,
Sep 23, 2011, 12:05:11 PM9/23/11
to android-...@googlegroups.com
Should we document this some place?, I can take the initiative, if someone can point me the place.

Thanks

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/R8USGGDoYq0J.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

David Herges

unread,
Sep 26, 2011, 1:08:42 PM9/26/11
to android-...@googlegroups.com
One thing to add:

if you modify the framework source in such a way that it requires a 'make update-api', you must also do 'make sdk' again. If not, the SDK will use an older version of the framework API and your application will get linked against that old API, i.e. the framework implements the API, however, applications are linked against a differing API. This could cause some problems, e.g. if constant values are changed, app and framework will use differing constant values; if method signatures are modified, calls will result in exceptions thrown by the DVM.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages