Android Library Projects Cause "already added" from dex

by Ian » Wed, 23 Feb 2011 22:51:13 GMT


Sponsored Links
 Hi all,

My Android project has multiple Android Library dependencies. Two of them 
use the ORMlite JAR so they each have that JAR in their libs directory so we 
can build the individual projects with Eclipse. However, when I try to build 
the overall Android project with ant, the -dex step complains that the 
classes from the ORMlite JAR were already added.

I suppose this makes sense (since dex is adding the classes from the 
dependencies, there are in fact two ormlite JARs whose classes are being 
added), but is there a way to specify that these JARs should not be included 
in the dex process?

Thanks!

-- 



Re: Android Library Projects Cause "already added" from dex

by Xavier Ducrohet » Thu, 24 Feb 2011 01:52:05 GMT


 It's not possible at this time to exclude them.

I believe the error is actually only a warning, in which case you could
ignore it?








-- 
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
 http://developer.android.com  |  http://tools.android.com 

Please do not send me questions directly. Thanks!

-- 


Sponsored Links


Re: Android Library Projects Cause "already added" from dex

by Ian Dees » Thu, 24 Feb 2011 01:59:58 GMT


 've attached the output of my "ant debug" run at the command line.
Unfortunately it exits with a build failure so I cannot ignore and continue.

On Wed, Feb 23, 2011 at 11:52 AM, Xavier Ducrohet <x...@android.com> wrote:


--
$ ant debug
Buildfile: /home/iandees/AndroidWorkspace/AndrApp/build.xml
[setup] Android SDK Tools Revision 8
[setup] Project Target: Android 2.2
[setup] API level: 8
[setup]
[setup] ------------------
[setup] Resolving library dependencies:
[setup] /home/iandees/AndroidWorkspace/AndrApp: common =>
/home/iandees/AndroidWorkspace/AndrApp/common
[setup] /home/iandees/AndroidWorkspace/AndrApp: map =>
/home/iandees/AndroidWorkspace/AndrApp/map
[setup] /home/iandees/AndroidWorkspace/AndrApp: network =>
/home/iandees/AndroidWorkspace/AndrApp/network
[setup] /home/iandees/AndroidWorkspace/AndrApp: map-domain =>
/home/iandees/AndroidWorkspace/AndrApp/map-domain
[setup] /home/iandees/AndroidWorkspace/AndrApp: location/ =>
/home/iandees/AndroidWorkspace/AndrApp/location
[setup] /home/iandees/AndroidWorkspace/AndrApp: domain-location/ =>
/home/iandees/AndroidWorkspace/AndrApp/domain-location
[setup] /home/iandees/AndroidWorkspace/AndrApp/domain-location:
../location/ => /home/iandees/AndroidWorkspace/AndrApp/location
[setup] /home/iandees/AndroidWorkspace/AndrApp/map-domain: ../network =>
/home/iandees/AndroidWorkspace/AndrApp/network
[setup] /home/iandees/AndroidWorkspace/AndrApp/map-domain: ../common =>
/home/iandees/AndroidWorkspace/AndrApp/common
[setup] /home/iandees/AndroidWorkspace/AndrApp/map-domain: ../map =>
/home/iandees/AndroidWorkspace/AndrApp/map
[setup] /home/iandees/AndroidWorkspace/AndrApp/map: ../network =>
/home/iandees/AndroidWorkspace/AndrApp/network
[setup] /home/iandees/AndroidWorkspace/AndrApp/map: ../common =>
/home/iandees/AndroidWorkspace/AndrApp/common
[setup] /home/iandees/AndroidWorkspace/AndrApp/map: ../network =>
/home/iandees/AndroidWorkspace/AndrApp/network
[setup] /home/iandees/AndroidWorkspace/AndrApp/map: ../common =>
/home/iandees/AndroidWorkspace/AndrApp/common
[setup] ------------------
[setup] Ordered libraries:
[setup] /home/iandees/AndroidWorkspace/AndrApp/map-domain
[setup] /home/iandees/AndroidWorkspace/AndrApp/map
[setup] /home/iandees/AndroidWorkspace/AndrApp/network
[setup] /home/iandees/AndroidWorkspace/AndrApp/common
[setup] /home/iandees/AndroidWorkspace/AndrApp/domain-location
[setup] /home/iandees/AndroidWorkspace/AndrApp/location
[setup] ------------------
[setup]
[setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is
lower than the project target API level (8)
[setup]
[setup] Importing rules file: tools/ant/main_rules.xml

-debug-obfuscation-check:

-set-debug-mode:

-compile-tested-if-test:

-dirs:
[echo] Creating output directories if needed...

-pre-build:

-resource-src:
[echo] Generating R.java / Manifest.java from the resources...

-aidl:
[echo] Compiling aidl files into Java classes...

-pre-compile:

compile:
[javac] /home/iandees/android-sdk-linux_86/tools/ant/main_rules.xml:361:
warning: 'includeantruntime' was not set, defaulting to
build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 16 source files to
/home/i



Re: Android Library Projects Cause "already added" from dex

by Xavier Ducrohet » Thu, 24 Feb 2011 02:51:31 GMT


 ah that is annoying. As a workaround you could create another library
that has no code/resources but only the jar file and make both of the
library that needs the jar file depend on it.

Xav








-- 
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
 http://developer.android.com  |  http://tools.android.com 

Please do not send me questions directly. Thanks!

-- 



Other Threads

1. problem with Hello, Gallery R.styleable not resolve

I had this same problem.  After days of searching online, I found this
workaround:

- Create a resources.xml file with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-stylable name="Gallery1">
        <attr name="android:galleryItemBackground" />
    </declare-stylable>
</resources>

- Instead of using android.R.styleable.Gallery1 just reference
R.styleable.Gallery1

Hope this helps!  I set this up a long time ago... If I missed something let
me know so I can post that missing information.

Thanks,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------






--~--~---------~--~----~------------~-------~--~----~

2. eclipse error: missing required Java project

In order to help with this, we would need more information about how your
project is set up....

--~--~---------~--~----~------------~-------~--~----~

3. onDraw issue? -- what's going on?!

4. Jaimin's Birthday Calendar

5. I permanently fail to unsubscribe from this mailing list

6. Flurry?

7. Publishing Upgrades on Android Market ... Still Relevant?