crash with NoSuchMethodError after proguard with method references

后端 未结 4 1108
难免孤独
难免孤独 2021-01-18 01:21

the source code before compile&proguard :

public class IntentSession extends BaseIntentSession {
    @Override
    public void onResume() {
        super         


        
4条回答
  •  醉话见心
    2021-01-18 01:54

    after re-check carefully, i concluded it probably not a bug of proguard, only gradle.

    first, i let the source code using general interface coding style :

    mExecutor.exec(getIntent(), new MyInterface() {
        @Override
        public void execute() {
            finish();
        }
    });
    

    then i clean the build cache and rebuild :

    ./gradlew clean
    ./gradlew :app:assembleRelease
    

    I perform the output release app and make it reach the problematic code, it work without crash.

    this time i turn to method references :

    mExecutor.exec(getIntent(), this::finish);
    

    but i didn't clean the build cache before re-building :

    ./gradlew :app:assembleRelease
    

    now re-perform with the crash happen :

    05-22 11:35:33.870 D/AndroidRuntime(  631): Shutting down VM
    05-22 11:35:37.470 E/AndroidRuntime(  631): FATAL EXCEPTION: main
    05-22 11:35:37.470 E/AndroidRuntime(  631): Process: com.cmrobot.assistant, PID: 631
    05-22 11:35:37.470 E/AndroidRuntime(  631): java.lang.NoSuchMethodError: com.session.a.finish
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.b.executeDone(Unknown Source)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.base.a.a(BaseIntentExecutor.java:99)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.base.a.e(BaseIntentExecutor.java:76)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.base.a.a(BaseIntentExecutor.java:67)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.cmd.general.volume.VolumeChangeExecutor.b(VolumeChangeExecutor.java:28)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.cmd.general.volume.a.a(LowerVolumeExecutor.java:63)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.base.a.d(BaseIntentExecutor.java:44)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.newsessions.base.b.run(Unknown Source)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at android.os.Handler.handleCallback(Handler.java:733)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at android.os.Handler.dispatchMessage(Handler.java:95)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at android.os.Looper.loop(Looper.java:136)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at android.app.ActivityThread.main(ActivityThread.java:5001)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at java.lang.reflect.Method.invokeNative(Native Method)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at java.lang.reflect.Method.invoke(Method.java:515)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
    05-22 11:35:37.470 E/AndroidRuntime(  631):     at dalvik.system.NativeStart.main(Native Method)
    

    in order to confirm it is the build cache reason, i clean then re-build on the changed code basically :

    ./gradlew clean
    ./gradlew :app:assembleRelease
    

    that crash gone in the afterword app.

    i attempt to create a demonstrating project to prove this problem, but that project doesn't popup the crash, only in my productive project.

提交回复
热议问题