Search Unity

Resolved Android build issue switching from 2021.3 to 2022.3

Discussion in 'Android' started by RonanBelUbisoft, Jun 2, 2023.

  1. RonanBelUbisoft

    RonanBelUbisoft

    Joined:
    Feb 1, 2022
    Posts:
    4
    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.
     
    Last edited: Jun 2, 2023
  2. unity_5CDECF02394F75355773

    unity_5CDECF02394F75355773

    Joined:
    Jul 3, 2022
    Posts:
    1
    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).
     
    StefanWSM, varan941, minakoh and 12 others like this.
  3. alemnunez

    alemnunez

    Joined:
    Mar 15, 2023
    Posts:
    6
    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. RonanBelUbisoft

    RonanBelUbisoft

    Joined:
    Feb 1, 2022
    Posts:
    4
    thank you VERY MUCH
     
  5. Davex6

    Davex6

    Joined:
    Mar 29, 2023
    Posts:
    49
    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.
     
  6. hiccupteacupyuvraj

    hiccupteacupyuvraj

    Joined:
    Mar 27, 2021
    Posts:
    3
    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
     
    Lorrak and elaine_unity694 like this.
  7. Eozgungor

    Eozgungor

    Joined:
    Jun 10, 2022
    Posts:
    4
    I fixed it by downloading API level 33 in android studio and attaching it to unity. This video helped me to fix it :
     
    varan941, Lorrak and Shodan0101 like this.
  8. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    232
    Yes, it works with API 33, so if you're using 2021 LTS, API 33 is the only solution now.
     
  9. JulienPlayrion

    JulienPlayrion

    Joined:
    Oct 21, 2021
    Posts:
    5
    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.
     
    Shodan0101 likes this.
  10. JackAidley

    JackAidley

    Joined:
    Aug 31, 2020
    Posts:
    8
    Thanks for fix, unity_somenumbers :)

    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.
     
  11. JulienPlayrion

    JulienPlayrion

    Joined:
    Oct 21, 2021
    Posts:
    5
    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!
     
  12. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    232
    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.
     
    Hunter-PrimeUnity likes this.
  13. dannymcrae

    dannymcrae

    Joined:
    Oct 26, 2020
    Posts:
    1
    I dont normally reply to these threads but you have saved me from a torturous existence my friend.
     
  14. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    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.
     
    daryl1112, RuanAzevedo and Lorrak like this.
  15. dylaragames

    dylaragames

    Joined:
    Sep 15, 2021
    Posts:
    1
    Thank you!
     
  16. RuanAzevedo

    RuanAzevedo

    Joined:
    May 14, 2022
    Posts:
    1
    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.
     
    Last edited: Jul 24, 2023
    Splendidus likes this.
  17. FatherMaGGus

    FatherMaGGus

    Joined:
    Aug 11, 2023
    Posts:
    1

    You are the best! Thank you 1000 times!
     
  18. soomon

    soomon

    Joined:
    Sep 24, 2020
    Posts:
    10
    thank you!!!!
     
  19. Hunter-PrimeUnity

    Hunter-PrimeUnity

    Joined:
    Sep 6, 2020
    Posts:
    4
    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 !