I recently activated ProGuard for my Android Eclipse project. After adding external libs and dynamically referenced classes in proguard.cfg, I don't get any errors when creating apk. However, I get a NoSuchMethodError when I try to run an installed application.
I narrowed it down to a specific method called the onCreate method of the main action. To simplify things, this is what the class and method look like (I forgot a lot of code, but I think this should illustrate it):
public class TestMain extends TabActivity implements OnSharedPreferenceChangeListener{
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
testMethod();
}
}
testMethod () is defined as follows:
private void testMethod() {
int charsLeft = maxPostMessageLength - someEditText.length();
...
}
someEditText.length(), . , , , , , - EditText.length(). , , , "someEditText.length()" testMethod onCreate:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
test = someEditText.length();
testMethod();
}
- , someEditText.length() onCreate, , onCreate?
Proguard , .
:
-dontshrink, -dontobfuscate -dontoptimzie proguard.cfg. -dontoptimize .
, , .