But within the typical Android build process, ProGuard runs post-compilation and pre- APK creation:
So within EBuild, I would imagine this would need to be the first sub-Task of ElementsPostCompileCooper, or at least before Task AndroidPack is run. Is there any way to tweak the build chain to add custom tasks? If not, I would love to see ProGuard added as a new, optional sub-Task of ElementsPostCompileCooper.
Right now there’s no way to do that, no. But if you can let me know specifics of what needs to be done/rund here (the more concrete the better), I can probably find time to integrate this sometime soon.
Thanks Marc, I think I’ve run across this in the docs but had forgotten about it. I want to obfuscate code in release builds, and I need to be able to deobfuscate stack traces generated by release builds. In a perfect world, Elements would provide a ProGuard-format mapping.txt file that I could upload to the Google Play Developer Console to deobfuscate stack traces within the Developer Console. But at the very least, I would need to be able to download stack traces and manually deobfuscate. I assume this is possible since a .fx file can be used to reference non-obfuscated names, but I don’t see anything about deobfuscation in the docs.
Unless I’m misunderstanding Aspects, I believe I found a bug related to this. The project appears to build correctly if I place the [assembly:Obfuscate] aspect in the implementation section of a file, but I get build error "E: unexpected number of compiler output files" if I place it anywhere in the interface section. This is true of a newly created Android project as well.
I just realized, I believe the test case I uploaded has the aspect in the implementation section. Moving it to the interface section causes that error on my machine though.
EDIT: Here’s the same project with the aspect in the interface section (fails on my machine)
Odd. I think the reverse is actually the case. the aspect seems to be ignored in implementing dentation section (thats a bug), when I move it to interface, it *compiles< but fails with
D: CompilerOutput for Cooper-Android
D: - <CompilerOutput: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/tests.obfuscate-793DAC6F94C24AAE788CFCD70B8A0F875B955E8D/Debug/Cooper-Android/tests.obfuscate.fx [Target: Cooper-Android]>
D: - <CompilerOutput: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/tests.obfuscate-793DAC6F94C24AAE788CFCD70B8A0F875B955E8D/Debug/Cooper-Android/tests.obfuscate.jar [Target: Cooper-Android]>
...
E: Unexpected number of compiler output files.
which seems to be an ebuild bug I’ll investigate now. It seems later parts of the Android toolchain do not expect non-.jar files (ie the .fx or the map) being generated by the compiler.
Great. Is the fix for the aspect being ignored or for the compilation not working? Once the compilation is working correctly (if not already) could I get a private build of this when you get a chance? I’m planning to push a release asap and would really like to have this functionality in it.
The Ebuild fix I made is for the build failing later, after the compile did obfuscate. I’ve started a new full produce t build and will send you a new installer once its done in ~1h. You should then be good to go with he aspect in the interface section.
The build is running and compiling correctly now with assmebly:Obfuscate in the interface section, but the code still does not seem to be obfuscated, at least not looking at the stack traces. I created a new test project where onCreate calls doSomething, which calls doSomethingElse, which intentionally crashes with a null pointer. I ran the same app with debug symbols Off and with them On, and neither stack trace is what I would expect from obfuscated code…
Without Debug Symbols:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at tests.obfuscate.__Global.doSomethingElse (Unknown Source:1)
at tests.obfuscate.MainActivity.doSomething (Unknown Source:0)
at tests.obfuscate.MainActivity.onCreate (Unknown Source:9)
With Debug Symbols:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at tests.obfuscate.__Global.doSomethingElse (C:\Users\mattr\Code\Elements\tests.obfuscate\MainActivity.pas:45)
at tests.obfuscate.MainActivity.doSomething (C:\Users\mattr\Code\Elements\tests.obfuscate\MainActivity.pas:39)
at tests.obfuscate.MainActivity.onCreate (C:\Users\mattr\Code\Elements\tests.obfuscate\MainActivity.pas:34)
Expected something like:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at a.a.a (a.a.a:1)
at a.b.a (a.b.a:0)
at a.b.b (a.b.b:9)