Android: Proguard NoSuchMethodError

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 . , , .

+3
4

. , , : @Override, . , - , Eclipse: " " Eclipse

, , Java 1.5, ProGuard , -dontoptimize, , 1.6. ...

, , , EditText.length() .

+1

Proguard : " ProGuard , , ".

, "" , .

-dontshrink

proguard.cfg

, , use.txt. , , , , . .

+1

, , . , . , ProGuard. ProGuard, , .

0

OP, proguard, -allowaccessmodification, .

0

Source: https://habr.com/ru/post/1785878/


All Articles