App crashing after upgrading android gradle plugin to 7

After updating from 4.1.3 to 7.0.0 the builds generated by CircleCI are crashing:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package.MainActivity}:java.lang.NullPointerException: setContentView(this, R.layout.activity_main) must not be null

No change to the related code was made, and if I build the app locally by executing the same command, I got no crashes.
I tried to update to java 11 as described here, but no lucky.

Does anyone have any idea what else can be done?


Would it be possible to confirm the version of Gradle you are using locally as the issue could be that your local version is not 7.0.0 this can be changed using the following guide:

The other suggestion is to check your import and update it due to the changes between the different versions of Gradle.

If neither of these issues help to resolve your issue please feel free to raise a support ticket using the link here:

I’m sorry for the delayed reply.
I’m using gradle version 7.3.1, which is declared in the file.
The package name is also correct, in the description of this issue I did use com.package.MainActivity for privacy reasons, but in the real project this is correct.
I’ll raise a ticket for the support.
Thank you!