Example
Obfuscation with ProGuard results in changes to file names and to code as displayed in these examples.
The following figure shows the StarterApplication APK .jar file
before and after obfuscation:
Figure 1.
The following code is the content of the StarterApplication APK Java™ file before obfuscation.
package com.StarterApplication;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import com.worklight.androidgap.api.WL;
import com.worklight.androidgap.api.WLInitWebFrameworkListener;
import com.worklight.androidgap.api.WLInitWebFrameworkResult;
import org.apache.cordova.CordovaActivity;
public class StarterApplication extends CordovaActivity
implements WLInitWebFrameworkListener
{
private void handleWebFrameworkInitFailure(WLInitWebFrameworkResult paramWLInitWebFrameworkResult)
{
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setNegativeButton(2130968579, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt)
{
StarterApplication.this.finish();
}
});
localBuilder.setTitle(2130968578);
localBuilder.setMessage(paramWLInitWebFrameworkResult.getMessage());
localBuilder.setCancelable(false).create().show();
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
WL.createInstance(this);
WL.getInstance().showSplashScreen(this);
WL.getInstance().initializeWebFramework(getApplicationContext(), this);
}
public void onInitWebFrameworkComplete(WLInitWebFrameworkResult paramWLInitWebFrameworkResult)
{
if (paramWLInitWebFrameworkResult.getStatusCode() == WLInitWebFrameworkResult.SUCCESS)
{
super.loadUrl(WL.getInstance().getMainHtmlFilePath());
return;
}
handleWebFrameworkInitFailure(paramWLInitWebFrameworkResult);
}
}
The following code is the content of the Java file after obfuscation:
package com.StarterApplication;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.os.Bundle;
import com.worklight.androidgap.b.c;
import com.worklight.androidgap.b.d;
import org.apache.cordova.CordovaActivity;
public class StarterApplication extends CordovaActivity
implements c
{
public final void a(d paramd)
{
if (paramd.a() == 0)
{
super.loadUrl(com.worklight.androidgap.b.a.b().c());
return;
}
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setNegativeButton(2130968579, new a(this));
localBuilder.setTitle(2130968578);
localBuilder.setMessage(paramd.b());
localBuilder.setCancelable(false).create().show();
}
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
com.worklight.androidgap.b.a.a(this);
com.worklight.androidgap.b.a.b();
com.worklight.androidgap.b.a.b(this);
com.worklight.androidgap.b.a.b().a(getApplicationContext(), this);
}
}