Android: Gradle build task adds a final keyword to a method

Viewed 21

I'm experiencing something strange, that never happened to me before. This is simple class that extends an Application class:

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
    }

}

It is a library module, than I try to extend it from an application module:

public class MyApp extends MyApplication {

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i("MyApp", "Application created");

    }
}

Now when compiling with minifyEnabled=true I'm getting strange result: In library module class get changed to (note the final keyword):

public class MyApplication extends Application {
    MyApplication() {
    }

    public final void onCreate() {
        super.onCreate();
    }
}

And this causes compilation error, since MyApp cannot override a final method. Did someone faced this issue? Thanks in advance. Happens only with minify enabled. Class MyApplication is added to proguard-rules as exception. Happens only on Gradle > 7.1.3. Reverting to 7.1.3 fixes the cause.

0 Answers
Related