[android-developers] Re: Reasoning behind disabling certain ProGuard optimizations?

2010-12-23 Thread Mark Lowne
[insert lengthy and passionate +1/me too implementation]

Also:
  there are much
more complicated optimizations to the byte code that Dalvik doesn't
handle well.

I'd like to know more about that as well!


On Dec 7, 6:34 pm, Matt Quigley matthew.quig...@gmail.com wrote:
 In the latest Android SDK Tools (revision 8), ProGuard has been
 integrated into the ant build.  This is easier to set up than it was
 before (http://www.androidengineer.com/2010/07/optimizing-obfuscating-
 and-shrinking.html), but I'm curious about the optimizations that are
 disabled by default.

 From the proguard.cfg file created with android update project -p .:
 -optimizations !code/simplification/arithmetic,!field/*,!class/merging/
 *

 #1: code/simplification/arithmetic: This removes things like turning
 3 + 3 into 6.  A shame, but understandable, because there are much
 more complicated optimizations to the byte code that Dalvik doesn't
 handle well.  This one is completely understood.

 #2: !field/*: This refers to the following:
 field/removal/writeonly - Removes write-only fields.
 field/marking/private - Marks fields as private, whenever possible.
 field/propagation/value - Propagates the values of fields across
 methods.

 #3: !class/merging/*: This disables merging two or more classes
 horizontally or vertically (in the same class hierarchy).

 The question here is, why would #2 and #3 give Android or Dalvik any
 problems?  The classes are valid Java classes in the end.  I suspect
 the answer for #2 is that projects built into Android require that the
 R.* classes to remain intact.  However, this is NOT the case for
 private apps created by developers, unless they use introspection to
 access those fields.  There is no need for the R class at all; all of
 the constants of that class can be propagated into whomever uses them,
 and the the R class can be removed.  For #3, this might have something
 to do with the fact that Views referenced in layout .xml files are
 dynamically created at runtime by reflection, and maybe merging these
 classes together messes them up.  But isn't that prevented by -keep
 public class * extends **View?

 For over a year I've been obfuscating my app and #2 and #3 have never
 been used.  I don't plan on using them from now on, either.  Unless,
 someone can clarify why I shouldn't be enabling #2 and #3?

 Thanks!
 -Matt

 P.S. I would recommend adding the following to the next version of the
 Android SDK Tool's automatically generated proguard.cfg file:
 # Keep classes which are not directly referenced by code, but
 referenced by layout files.
 -keep public class * extends **View {
     public init(android.content.Context);
     public init(android.content.Context, android.util.AttributeSet);
     public init(android.content.Context, android.util.AttributeSet,
 int);
     public void set*(...);}

 This prevents classes which extend View, TextView, etc. classes from
 being renamed.  This will avoid ClassNotFoundExceptions when
 developers use custom View classes referenced in their layout files.
 It will hit some false positives (i.e. a class which ends with View
 may not actually be used as such), but that is acceptable IMHO, and
 can be easily changed by a developer as needed.

 An alternative is to use -keep public class * extends
 android.view.View, which removes all false positives, but will add
 some missed cases, such as a class which extends TextView.

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


[android-developers] Re: Tut (SDK 1.5) Get google account of user

2009-11-18 Thread Mark Lowne
Very interesting discussion! Thanks everybody for the precious info.

Did anyone manage to get BlockingHelper to work? (or, to put it
differently: is there any way to do this without the need for an
activity that receives the result?)

On Oct 12, 7:27 pm, kostmo kos...@gmail.com wrote:
 It seems I was the victim of an edge case.  I had not done a factory
 reset of my ADP1 since Android 1.1.  It works now! :)

 Karl

 On Oct 12, 1:13 am, kostmo kos...@gmail.com wrote:



  It seems tantalizingly close, but I still can't get the
  GoogleLoginService method to work with Google App Engine (GAE).

  I'll start with a review of the method that currently works for me.
  Let's say that myapp is my GAE application name and authstring
  is the 203-character string I get from ClientLogin.

  After using the user/pass prompt and traditional ClientLogin method, I
  can examine the cookie retrieved via curl:
  curl -c cookies.txt http://myapp.appspot.com/_ah/login?auth=authstring
  This command dumps HTML to the terminal and saves the cookie to
  cookies.txt.  The HTML sates that the status code is 302,
  but in actuality the HTTP status code is 204.  Anyway, these are
  characteristics of the cookie exchange working *properly*.
  The URL can be used repeatedly to get the cookie (although I don't
  know how long it stays valid).

  Now let me describe how I attempt to accomplish the same with
  GoogleLoginServiceHelper.  I am using the method described originally
  by Sujay where he iterates through the methods in the
  GoogleLoginServiceHelper class.  I look for the the getCredentials
  method that has the correct name and argument types and call it as
  follows:
  m.invoke(
          null,   // This extra argument pertains to the invoke method.
          this,
          12345,  // onActivityResult code
          null,
          true,   // value of the GoogleLoginServiceConstants.REQUIRE_GOOGLE
  constant
          ah, // This is the service parameter that supposedly works with 
  GAE
          false);

  In my Manifest file, I have
          uses-permission
  android:name=com.google.android.googleapps.permission.GOOGLE_AUTH/
  uses-permission
  in addition to
          uses-permission
  android:name=com.google.android.googleapps.permission.GOOGLE_AUTH.ah/
  uses-permission
  .

  The intent passed to onActivityResult has 3 string fields:
  callerExtras, authtoken (the value of the
  GoogleLoginServiceConstants.AUTHTOKEN_KEY constant), and
  authAccount.
  I encounter the same response as before, however: when substituting
  the authtoken value for authstring in the
  above curl command, the result is 500 Server error.

  I am determined to get this to work!  Is there possibly some
  configuration I'm missing on the App Engine side?

  Karl

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