We’ve never used Proguard until now, because the vast majority of our code is in Lua and therefore obfuscated when it’s turned into bytecode by Corona’s build process.
However we’re constantly running into Android’s 65k method count limit because we have integrated quite a number of libraries, so I’m now looking at Proguard as a way of (hopefully) stripping out any unused methods.
The problem is, I’m not really sure what I’m doing. I’ve enabled proguard in my project, and initially had loads of warnings such as
Warning: com.naef.jnlua.script.LuaScriptEngine: can't find referenced field 'javax.script.ScriptContext context' in class com.naef.jnlua.script.LuaScriptEngine
and notes such as
Note: com.ansca.corona.graphics.opengl.GLSurfaceView$GLThreadManager: can't find dynamically referenced class android.os.SystemProperties
Looking these kind of errors up online seemed to suggest that the solution was to use -dontwarn and -dontnote, but to me that seems like burying my head in the sand and pretending that the problems aren’t there.
I’m sure that if I go back and look at the integration docs for the various libs then I’ll find the proguard settings for those, but it seems that Corona’s own java code itself is encountering proguard problems.
I’ve added this to my proguard-project.txt:
-keep class com.quiztix.\*\* -keep class com.ansca.\*\*
The project builds ok, but when I run my apk I get the following:
02-10 14:28:40.183: W/dalvikvm(8411): Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lcom/ansca/corona/JavaToNativeShim; 02-10 14:28:40.183: W/dalvikvm(8411): Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lcom/ansca/corona/CoronaEnvironment; 02-10 14:28:40.183: D/AndroidRuntime(8411): Shutting down VM 02-10 14:28:40.183: W/dalvikvm(8411): threadid=1: thread exiting with uncaught exception (group=0x418e6da0) 02-10 14:28:40.183: E/AndroidRuntime(8411): FATAL EXCEPTION: main 02-10 14:28:40.183: E/AndroidRuntime(8411): Process: com.quiztix.movies, PID: 8411 02-10 14:28:40.183: E/AndroidRuntime(8411): java.lang.NoSuchFieldError: no field with name='luaState' signature='J' in class Lcom/naef/jnlua/LuaState; 02-10 14:28:40.183: E/AndroidRuntime(8411): at java.lang.Runtime.nativeLoad(Native Method) 02-10 14:28:40.183: E/AndroidRuntime(8411): at java.lang.Runtime.doLoad(Runtime.java:435) 02-10 14:28:40.183: E/AndroidRuntime(8411): at java.lang.Runtime.loadLibrary(Runtime.java:363) 02-10 14:28:40.183: E/AndroidRuntime(8411): at java.lang.System.loadLibrary(System.java:526) 02-10 14:28:40.183: E/AndroidRuntime(8411): at com.ansca.corona.JavaToNativeShim.\<clinit\>(Unknown Source) 02-10 14:28:40.183: E/AndroidRuntime(8411): at com.ansca.corona.CoronaEnvironment.a(Unknown Source) 02-10 14:28:40.183: E/AndroidRuntime(8411): at com.ansca.corona.CoronaEnvironment.\<clinit\>(Unknown Source) 02-10 14:28:40.183: E/AndroidRuntime(8411): at com.quiztix.movies.CoronaApplication.onCreate(Unknown Source) 02-10 14:28:40.183: E/AndroidRuntime(8411): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025) 02-10 14:28:40.183: E/AndroidRuntime(8411): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4581) 02-10 14:28:40.183: E/AndroidRuntime(8411): at android.app.ActivityThread.access$1600(ActivityThread.java:161) 02-10 14:28:40.183: E/AndroidRuntime(8411): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325) 02-10 14:28:40.183: E/AndroidRuntime(8411): at android.os.Handler.dispatchMessage(Handler.java:102) 02-10 14:28:40.183: E/AndroidRuntime(8411): at android.os.Looper.loop(Looper.java:157) 02-10 14:28:40.183: E/AndroidRuntime(8411): at android.app.ActivityThread.main(ActivityThread.java:5356) 02-10 14:28:40.183: E/AndroidRuntime(8411): at java.lang.reflect.Method.invokeNative(Native Method) 02-10 14:28:40.183: E/AndroidRuntime(8411): at java.lang.reflect.Method.invoke(Method.java:515) 02-10 14:28:40.183: E/AndroidRuntime(8411): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 02-10 14:28:40.183: E/AndroidRuntime(8411): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 02-10 14:28:40.183: E/AndroidRuntime(8411): at dalvik.system.NativeStart.main(Native Method)
I can’t see any examples of proguard being used in a Corona Enterprise project, and the few other Corona devs I know have also not used it.
Does anyone know how I can get it up and running?