Android build issue switching from 2021.3 to 2022.3

Hi, I’ve just tried 2022.3
The windows build runs fine, not the android one.
First I had errors during the build, some process trying to write to the file
2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml
which was not creatable due to file-system privileges when located in c:\programfiles
uninstalling from C: and re-installing to D: solved this issue (weird)

Then I get these errors, any help is welcome :

Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details

Task :unityLibrary:compileDebugJavaWithJavac FAILED

D:\Perforce\NFT\Library\Bee\Android\Prj\Mono2x\Gradle\launcher\src\main\AndroidManifest.xml:4:2-98 Warning:
uses-permission#android.permission.READ_EXTERNAL_STORAGE was tagged at AndroidManifest.xml:4 to replace another declaration but no other declaration present

Task :unityLibrary:compileDebugJavaWithJavac FAILED

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
D:\Perforce\NFT\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity\androidnotifications\UnityNotificationManager.java:164: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
^
symbol: variable TIRAMISU
location: class VERSION_CODES
D:\Perforce\NFT\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity\androidnotifications\UnityNotificationManager.java:165: error: cannot find symbol
permissionGranted = mContext.checkCallingOrSelfPermission(Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED;
^
symbol: variable POST_NOTIFICATIONS
location: class permission
Note: D:\Perforce\NFT\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

I think you have to download Android SDK 33. At least that fixed it for me.

This is how I did it.
1- Edit > Project Settings > Player > Minimum API Level > Android 13 (API version 33).
2- File > Build And Run

The build and run will ask you to download SDK 33 (if not already), you just have to confirm.

Don’t forget to set the Minimum API Level back to whatever version you need.
I think you should be able to do the same by modifying Target API Level to Android 13 instead of Minimum API Level (if you have it as an option).

18 Likes

Had the same problem. Can be fixed by changing “Edit > Project Settings > Player > Target API Level” to Android 13. Changing the Minimum API level would prevent the app from being released to older android versions.

4 Likes

thank you VERY MUCH

I remember reading a post from a Unity worker who said that a Bug Report should be made if the error messages were missing or confusing.

Oh My Lord bro, you saved me. I spent 10 days searching for a solution and thought that my code is causing this stupid error, reinstalling every single sdk, ndk and jdks. Thanks

2 Likes

I fixed it by downloading API level 33 in android studio and attaching it to unity. This video helped me to fix it :

3 Likes

Yes, it works with API 33, so if you’re using 2021 LTS, API 33 is the only solution now.

Hope this gets quickly fixed, it is annoying. Let’s hope target API 33 does not have too much breaking issues too for our project.

1 Like

Thanks for fix, unity_somenumbers :slight_smile:

To @hippogames and @JulienPlayrion - you can switch it back once you’ve done the build once and all is fine. It just needs to be set to 33 once to get it to install the right SDK.

I have reported this as a bug to Unity.

4 Likes

Thanks, this is not a solution that is compatible with a CI/CD environment though, unfortunately. Thank you for reporting the bug, don’t hesitate to share the issue’s link so we can vote for it!

No, this doesn’t work as the androidnotifications package requires API 33. I was able to downgrade com.unity.mobile.notifications to 2.1.1 by editing packages-lock.json and manifest.json. And now I can use API 31.

1 Like

I dont normally reply to these threads but you have saved me from a torturous existence my friend.

Mobile Notifications only require SDK 33 at compile time. For runtime it supports 21+.
You don’t need to change minimum API level, you can set target level to 33.
Alternatively you can modify gradle files to set compile sdk to 33, then your target sdk can be lower.

3 Likes

Thank you!

I had the same problem today and this fixed the problem, thanks!

Edit:
So, in my case, I have to support a couple of older devices so I left the settings like this:

  • Minimum API Level: Android 11.0 (API Level 30)
  • Target API Level: Automatic (highest installed)

Hope it helps anyone.

1 Like

You are the best! Thank you 1000 times!

thank you!!!

Worked for me as well. By removing the Mobile Feature pack, I was able to downgrade the notification package to 2.0.2 and set my Minimum API Level back to 22. Thank you !

ily