Every single time, I have problems building a single empty APK with nothing on my project.
I have been struggling for years!
Every time it is a different error that doesn’t let me work.
I stick with one JDK, I am upgrading my SDK based on the highest API level and still facing troubles.
Here a few tips from me (valid for Unity 2021 LTS):
You should just use the SDK that comes with Unity automatically
Make sure you select SDK+NDK in the Unity Hub Installer (not selected by default)
When changing to a different SDK version in unity it will automatically install the new sdk required.
The android device must have developer mode active and the computer must be allowed (check developer settings regularly as the device sometime revoke authorizations)
For Build&Run to work on newer Android phones you need to use wait for the USB popup and select “Android Auto” before starting the build
If you change any build settings such as Debug mode usually a Unity Editor restart is required (otherwise it can get confused)
Remove any apk still in the target folder and related files, otherwise the build will likely fail
If you use any Google Packages (i.e. External Dependency Manager) - make sure you have only one version of the dependency manager in the project (I recommend the one from the package manager)
If you import any third party packages you need to manually ensure you don’t import any conflicting dlls (such as external dependency manager)
If you update any third party assets make sure you manually delete all relevant files (mainly the Plugins folder)
Check the Plugins/* folders if there are any duplicate plugins (i.e. 2 versions of any plugin)
Check your AndroidManifest.xml for duplicates (you can do this easily by exporting the Gradle project)
If you use addressables and switch profiles you should also restart Unity - otherwise the build won’t properly work
If you see an error during device startup and it’s not related to addressables make sure to delete the Library folder related to builds (IL2CPP output)
For upload in Google Play you most likely need to build *.aab files now - for this you need the correct version of the Google Play Games Plugin to avoid conflicts (the app will crash with a wrong version)
So yes you are correct, the list of necessary workarounds grows, because the Unity Editor becomes more and more buggy.