Build errors - re: libraries?

291 views
Skip to first unread message

tech1

unread,
Jan 30, 2012, 7:49:33 AM1/30/12
to Maven Android Developers
Hi

I've recently done some updates through SDK Manager which included
moving up to ADT 16.

I also noticed the newer android-maven-plugin (3.0.2) was available
including the artifactId renaming.

I'm having problems compiling through Eclipse (Indigo), i.e. Run As
Android Application.

I hit this problem in my actual project but when I couldn't figure out
why thought of starting a new basic project using the following to see
if it still occurred, but I still don't know why and what can be done
to resolve, anyone help my understanding please, would be much
appreciated?

If I start a new Maven project in Eclipse and choose archetype;

de.akquinet.android.archetypes
android-quickstart
1.0.6

then;

platform = 8
emulator = not-specified (am using my phone instead)
android-plugin-version = 3.0.2 (changed the artifactId manually in the
pom after creation to 'andriod-maven-plugin')

Save pom, but now it gives a 'Plugin execution not covered by
lifecycle configuration: com.jayway.maven.plugin (Click for Details)'

2 quick fixes available;

Discover new m2e connectors (Doesn't find any)
Permanently mark goal proguard in pom.xml as ignored in Eclipse build
(I choose this for the time being)

I would eventually like to use proguard but the android-quickstart
archetype doesn't include it, so would be curious to know how to add
that to my project and then I presume remove the ignore entry from the
pom.

I then right click my new project in the Eclipse Package Explorer pane
on the left of the Eclipse window and choose Maven > Update Project
Configuration.

It builds the basic hello world type project framework which runs :-))

However, as soon as I add dependencies into the pom, such as adding
the latest Google API's Client Library for Java (v. 1.6.0-beta) I get
the following compile errors.

http://code.google.com/p/google-api-java-client/


This is how my pom looks after adding some dependencies...


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testtech1</groupId>
<artifactId>testtech1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>testtech1</name>

<repositories>
<repository>
<id>google-api-services</id>
<url>http://mavenrepo.google-api-java-client.googlecode.com/
hg</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-tasks</artifactId>
<version>v1-1.3.0-beta</version>
</dependency>

<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.6.0-beta</version>
</dependency>

<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-extensions</artifactId>
<version>1.6.0-beta</version>
</dependency>

<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-extensions-android2</
artifactId>
<version>1.6.0-beta</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</
groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<androidManifestFile>${project.basedir}/
AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</
assetsDirectory>
<resourceDirectory>${project.basedir}/res</
resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/
main/native</nativeLibrariesDirectory>
<sdk>
<platform>8</platform>
</sdk>
<deleteConflictingFiles>true</
deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e
settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.jayway.maven.plugins.android.generation2
</groupId>
<artifactId>
android-maven-plugin
</artifactId>
<versionRange>
[3.0.2,)
</versionRange>
<goals>
<goal>proguard</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>


My Project folder structure looks like this after saving the pom with
the above dependencies:

testtech1
+JRE System Library [JavaSE-1.6]
+Maven Dependencies
+Android 2.2
+gen [Generated Java Files]
+src/main/java
assets
+bin
+res
+src
+target
AndroidManifest.xml
pom.xml
project.properties





Eclipse Console output:

[2012-01-30 12:21:57 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come
with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:57 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come
with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:57 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come
with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:58 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with
an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:59 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come
with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:59 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:59 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:59 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:59 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:59 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$5) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:21:59 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$6) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-01-30 12:22:15 - testtech1] Dx
trouble processing "javax/xml/namespace/QName.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.

[2012-01-30 12:22:15 - testtech1] Dx 1 error; aborting
[2012-01-30 12:22:15 - testtech1] Conversion to Dalvik format failed
with error 1



Ricardo Gladwell

unread,
Feb 1, 2012, 11:18:45 AM2/1/12
to maven-androi...@googlegroups.com
Just tried to reproduce this, but cannot find the following dependency:

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-tasks</artifactId>
<version>v1-1.3.0-beta</version>
</dependency>

It doesn't look as though this is in the Maven central repository. Is it
a custom dependency?

--
Ricardo Gladwell <ricardo....@gmail.com>
http://www.google.com/profiles/ricardo.gladwell
Twitter: @rgladwell - MSN: axo...@gmail.com

tech1

unread,
Feb 1, 2012, 12:13:41 PM2/1/12
to Maven Android Developers
Hi Ricardo

Thanks for taking a look, did you include the following repository in
the pom?

<repositories>
<repository>
<id>google-api-services</id>
<url>http://mavenrepo.google-api-java-client.googlecode.com/
hg</url>
</repository>
</repositories>



On Feb 1, 4:18 pm, Ricardo Gladwell <ricardo.gladw...@gmail.com>
wrote:
> Just tried to reproduce this, but cannot find the following dependency:
>
>          <dependency>
>              <groupId>com.google.apis</groupId>
>              <artifactId>google-api-services-tasks</artifactId>
>              <version>v1-1.3.0-beta</version>
>          </dependency>
>
> It doesn't look as though this is in the Maven central repository. Is it
> a custom dependency?
>
> --
> Ricardo Gladwell <ricardo.gladw...@gmail.com>http://www.google.com/profiles/ricardo.gladwell
> ...
>
> read more »

tech1

unread,
Feb 1, 2012, 12:29:03 PM2/1/12
to Maven Android Developers
Also,

Since my original post and googling around I came across the following
post which seemed very like my issue. Following the info in that post
(i.e. commenting out the android artifactId dependency block) did
remove the errors referring to 'org.apache.commons.logging', but I now
get a couple of new errors instead.

http://androidthroughmaven.blogspot.com/2011_10_01_archive.html


[2012-02-01 13:36:04 - testtech1] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(org.joda.time.DateTimeZone$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a
compiler that did not target the modern .class file format. The
recommended
solution is to recompile the class from source, using an up-to-date
compiler
and without specifying any "-target" type options. The consequence of
ignoring
this warning is that reflective operations on this class will
incorrectly
indicate that it is *not* an inner class.
[2012-02-01 13:36:41 - testtech1] Dx
trouble processing "javax/transaction/HeuristicCommitException.class":
[2012-02-01 13:36:41 - testtech1] Dx 1 error; aborting
[2012-02-01 13:36:41 - testtech1] Conversion to Dalvik format failed
with error 1
> ...
>
> read more »

tech1

unread,
Feb 3, 2012, 6:47:05 AM2/3/12
to Maven Android Developers
Hi Ricardo,

I was just wondering if you have now been able to replicate this
problem?
> ...
>
> read more »

Ricardo Gladwell

unread,
Feb 4, 2012, 10:06:02 AM2/4/12
to maven-androi...@googlegroups.com
Hi tech1 (do you have a name?)

Sorry for the delay, got this working on my home laptop.

A quick review indicates that the problem is the third-party
dependencies from Google APIs Client Library for Java have several
dependencies themselves that aren't appropriate for Android build
environments. Please see the excludes in the following fixed POM:

https://gist.github.com/1738301

I'm not sure how well these APIs will work with the dependency I've
excluded, so you may need to mess around with them.

Problems include:

1. Include httpclient API: this comes with the Android API so it
should be in the provided scope in the upstream POM. Building with
Android classes like httpclient causes problems with the ADT which
will not build if these are in your Maven calsspath.
2. javax.transaction is not appropriate at all for Android, and should
not be included. The ADT will not build projects with java.* or
javax.* libraries in your Maven classpath.
3. Do you need to include all four google-api-* dependencies in your
POM, or only the google-api-client-extensions-android2?
4. Duplicate inclusion of class files between Google Guave and
google-collections: the ADT does not like including duplicate class
files and will not build if these are in your Maven classpath.

You should probably raise some of these issues with the Google APIs
Client Library for Java project: their
google-api-client-extensions-android2 has obviously not been properly
configured to work with the ADT and has inappropriate dependencies
that should either be marked as provided scope or removed altogether.

In future you can fix these problems yourself by looking at the error
messages and seeing which projects include the problem class files and
using Maven dependency excludes to remove them from your Eclipse Maven
classpath.

Hope this is useful, regards...

--
Ricardo Gladwell <ricardo....@gmail.com>

> --
> You received this message because you are subscribed to the Google Groups "Maven Android Developers" group.
> To post to this group, send email to maven-androi...@googlegroups.com.
> To unsubscribe from this group, send email to maven-android-deve...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/maven-android-developers?hl=en.
>

tech1

unread,
Feb 5, 2012, 12:46:41 PM2/5/12
to Maven Android Developers
Hi Ricardo,

Thanks for the very detailed posts, I'm Jason btw.

Following your reply I thought perhaps I had been wrong to include too
many of those Google API's Client Library for Java dependencies,
perhaps I had misinterpreted information that was intended for Java as
a whole rather than at the Android platform.

However, the following article which I went back to is aimed at an
Android audience and the earlier 1.4.1-beta of both the "Google API's
Client Library for Java", plus the "Google HTTP Core Library", the
article suggests multiple dependencies are required and also
specifically states to import further jars such as httpclient and
httpcore.

http://code.google.com/apis/tasks/articles/oauth-and-tasks-on-android.html

http://javadoc.google-api-java-client.googlecode.com/hg/1.4.1-beta/index.html

I do note though that the above article didn't include the "google-api-
client-extensions" or "google-api-client-googleapis-extensions"
dependencies so perhaps I can do without those too in the 1.6.0-beta.
Certainly that would seem to take account of points 2 & 4 that you
raised.

I found the following useful too, which I now see what you mean by the
upstream pom, I hadn't realised from Google's info that this even
existed, and can see that most of the dependencies stem from there.

http://search.maven.org/#search%7Cga%7C1%7Cgoogle-api-client

Having experimented with the fixed pom you kindly provided, I tried
omitting "google-api-client" and "google-api-client-extensions"
artifactId dependencies and the result appears to include much of what
is being discussed in the article above referring to the oAuth and
Google Tasks API examples with the 1.4.1-beta. In fact I then went on
to try adding "google-api-client" back and it didn't affect the
available jars in the "Maven Dependencies" folder or the packages
shown in each jar, even though the project dependencies refreshed. I
guess that is due to "google-api-client-extensions-android2" referring
to the parent pom?

I'm curious to your comments relating httpclient API as I had not seen
any mention of that in my errors, was that your own prior knowledge
that seeing that in the "Maven Dependencies" folder was something you
knew to be a duplicate of what is in the Android.jar?

I think in response to the problem points you've raised, I don't think
all the dependencies were required and if it looked like the following
that would also account for points 2 & 4 you raised.

<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-tasks</artifactId>
<version>v1-1.3.0-beta</version>
<exclusions>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-extensions-android2</artifactId>
<version>1.6.0-beta</version>
<exclusions>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

I shall raise this with the Google API's Client Library for Java
Project with reference to the inappropriate dependencies and whether
the above dependency logic of only including the "google-api-client-
extensions-android2" is indeed correct.


Kind regards
Jason



On Feb 4, 3:06 pm, Ricardo Gladwell <ricardo.gladw...@gmail.com>
wrote:
> ...
>
> read more »

Ricardo Gladwell

unread,
Feb 6, 2012, 5:35:47 AM2/6/12
to maven-androi...@googlegroups.com
On 05/02/12 17:46, tech1 wrote:
> Hi Ricardo,
>
> Thanks for the very detailed posts, I'm Jason btw.

Hi Jason :)

> I'm curious to your comments relating httpclient API as I had not seen
> any mention of that in my errors, was that your own prior knowledge
> that seeing that in the "Maven Dependencies" folder was something you
> knew to be a duplicate of what is in the Android.jar?

These issues are slightly difficult to trace: in this case, the error
message you got was for the commons-logging API, which is a dependency
of the httpclient API.

> I shall raise this with the Google API's Client Library for Java
> Project with reference to the inappropriate dependencies and whether
> the above dependency logic of only including the "google-api-client-
> extensions-android2" is indeed correct.

Thanks, please post any URLs to issue tickets or mailing list threads so
I can track the conversation.

In the meantime, did you get your Android app working with the Google APIs?

--
Ricardo Gladwell <ricardo....@gmail.com>

tech1

unread,
Feb 6, 2012, 9:33:48 AM2/6/12
to Maven Android Developers
Hi Ricardo,

I haven't yet coded my app with Google API stuff as I started from the
opposite end of things you might say, i.e. database and provider
classes etc as I want to sync data between my app's local db and
Google's service.

I have now raised this on stackoverflow as suggested by the Google
Code home for this library.

http://stackoverflow.com/questions/9161405/google-apis-client-library-for-java-1-6-0-beta-correct-dependencies-jars-for

Cheers
Jason


On Feb 6, 10:35 am, Ricardo Gladwell <ricardo.gladw...@gmail.com>
wrote:
> Ricardo Gladwell <ricardo.gladw...@gmail.com>http://www.google.com/profiles/ricardo.gladwell
Reply all
Reply to author
Forward
0 new messages