henriqueolliveira / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Depend on Guava library #96

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
External references, such as a standards document, or specification?

http://code.google.com/p/guava-libraries/

Java environments (e.g. Java 6, Android 2.2, App Engine 1.3.7, or All)?

All.

Please describe the feature requested.

Currently we copy two classes from Guava from the com.google.common.base 
package.  See:

http://code.google.com/p/google-api-java-client/source/browse/#hg%2Fgoogle-api-c
lient%2Fsrc%2Fcom%2Fgoogle%2Fapi%2Fclient%2Frepackaged%2Fcom%2Fgoogle%2Fcommon%2
Fbase

Instead we should just depend on Guava directly.  Although this adds a 1MB 
dependency, with ProGuard this will presumably reduce to a trivial size.  This 
is a particularly important considerations for environments like Android with 
low application space, so we need to verify this claim that ProGuard can be 
used effectively with this library.

Original issue reported on code.google.com by yan...@google.com on 7 Jan 2011 at 3:42

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 8 Jan 2011 at 6:19

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 26 Jan 2011 at 3:07

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 27 Jan 2011 at 8:34

GoogleCodeExporter commented 9 years ago
"with ProGuard this will presumably reduce to a trivial size"

From a practical standpoint I can hardly agree with that claim. My APK is 
~430kB with version 1.2.x of the library. Same code, bar the small changes 
required to match the new API, is almost twice the size (800kB) with version 
1.3.x of the library. This is not trivial by any standard.

Both builds use the attached ProGuard config.

I think this library should either repackage Guava into separate files or 
import only those parts of Guava that it really needs, as was the case in the 
1.2.x tree.

Original comment by ptas...@gmail.com on 21 Apr 2011 at 11:12

Attachments:

GoogleCodeExporter commented 9 years ago
For reference the calendar-v2-atom-android sample linked below compiles to 
shrinks to a roughly 40KB application with the Guava dependency:

http://samples.google-api-java-client.googlecode.com/hg/calendar-v2-atom-android
-sample/instructions.html?r=default

So I suspect it is not a "dependency on guava" issue.  It would be very 
surprising to me since the amount of guava code actually used by the library is 
trivially small.

That said, your ProGuard file looks good to me, and it is clear that you are 
measuring the ProGuard size since otherwise it would be a lot more than 800kB.  
What I recommend you do as the next step is to take a look at the mapping.txt 
file that proguard generated and try to debug what ProGuard is actually 
retaining.  For example, how much of com.google.common is being used?  If 
possible, please attach the subset of the mapping.txt file that you are able to 
share, at least for the non-confidential parts involving com.google.common.

Original comment by yan...@google.com on 21 Apr 2011 at 12:01

GoogleCodeExporter commented 9 years ago
Now this is puzzling. Based on ProGuard output none of com.google.common is 
used. Yet, if I remove guava as a dependency for the project, and thus reduce 
app size do ~476kB, the resulting APK fails immediately when the 
google-api-java-client libary functionality is invoked. Excuse my ignorance, 
but even if none of guava is used the dependency remains?

What's even more puzzling is that with the older 1.2.x release, under same 
build process, the library was hardly adding any weight to the APK, somewhere 
around 25kB at most.

I am using ant 1.8 for my builds and include 3rd party libs the standard way - 
"libs" folder in project path + a pointer to the lib file in Eclipse project 
classpath.

This makes me wonder, whether the way the library is referenced in a standard 
Eclipse project should change for 1.3, compared to 1.2?

Original comment by ptas...@gmail.com on 27 Apr 2011 at 2:48

GoogleCodeExporter commented 9 years ago
As a test I have setup a blank "hello world" project and let Maven take care of 
dependencies. This is how it looks like in the pom.xml file:

<dependency>
      <groupId>com.google.api.client</groupId>
      <artifactId>google-api-client-googleapis</artifactId>
      <version>1.3.1-alpha</version>
      <exclusions>
        <exclusion>
          <artifactId>jsr305</artifactId>
          <groupId>com.google.code.findbugs</groupId>
        </exclusion>
      </exclusions>
    </dependency>

There is no code that calls any of the client API, so technically speaking the 
resulting APK should be very small. It's not the case, as the APK ends up being 
400kB. Removing the com.google.api.client dependency results in a 16kB APK. If 
two different build models (ant v. maven) result in the same problem, it would 
seem there might indeed be a problem with how the new version is packaged.

Original comment by ptas...@gmail.com on 3 May 2011 at 1:29