Running automated tests on obfuscated app (gradle, ProGuard/Dexguard)

1,519 views
Skip to first unread message

Ivan Biryukov

unread,
Feb 24, 2014, 7:04:36 AM2/24/14
to adt...@googlegroups.com
Hello!

We are investigating possibility to use ProGuard or DexGuard to obfuscate our code.
We also have a bunch of Robotium automated tests. We have a problem when we build the app with obfuscation enabled.  The classes in the app project are obfuscated, but the references to those classes in the tests are not. Hence tests fail right away. 

In Proguard/DexGuard there is an option to apply mapping from previous build to the next one. But I can't find a place where to put this option for tests, so that classes will be renamed according to obfuscation mapping. I think we need to put this option into buildType used for building tests, but I can't find how to access it. Does anyone now how to do that?

Thanks!

Xavier Ducrohet

unread,
Feb 24, 2014, 12:19:35 PM2/24/14
to adt...@googlegroups.com
I think I added support for this, but I'll have to double check. You shouldn't have to manually go and input this yourself. If the tested variant is proguarded, the mapping file should be automatically injected when compiling the test app.




--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



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

Please do not send me questions directly. Thanks!

Thomas Keller

unread,
Oct 14, 2014, 6:35:25 PM10/14/14
to adt...@googlegroups.com
Hi Xavier!

I tried to enable proguard (w/o obfuscation) on my debug build with identical rules of those of my release build and get a ClassDefNotFoundException of a 3rd party library class right on the start of my instrumentation test, which I do not get when I run the proguarded release build of my app.

At first I thought this is an entirely unsupported use case, which is why I created a feature request for it on the bug tracker: https://code.google.com/p/android/issues/detail?id=77475, but reading that here apparently it is not. Since my project is private and reasonably large it would not make sense to go much into details at this point; instead, I would like to know more at first about the mechanics behind and if more specific configuration is needed which I might miss.

I already figured out that giving my debug build an additional -injars ... setting for the "test app" that points to the created build/intermediates/classes-proguard/debug/classes.jar is pointless since this is the file proguard puts the remaining classes in for the debug apk itself. (I had this idea after reading http://blog.xebia.com/2013/08/04/android-tests-with-proguard)

Any help would be greatly appreciated!

Thanks,
Thomas.

Michal Bendowski

unread,
Dec 11, 2014, 12:42:55 PM12/11/14
to adt...@googlegroups.com
Hi Thomas,

Please see my comment on the bug - can you provide us with more information? I would like to understand what exactly we need to do and solve the issue.

Thanks,

Michal
Reply all
Reply to author
Forward
0 new messages