Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug Unity 6 Preview: Android NDK Compatibility Issue

Discussion in 'Android' started by IndigoGorki, May 4, 2024.

  1. IndigoGorki

    IndigoGorki

    Joined:
    Mar 2, 2018
    Posts:
    39
    Hello,

    I'm encountering an issue with the NDK version compatibility. Everything runs smoothly with Unity version 2023.2.4f, including successful builds. However, upon switching to Unity 6 preview, the build process halts without any errors, citing an NDK version mismatch.

    Despite not altering the NDK configuration, I've consistently relied on the versions bundled with Unity's SDK and JDK during installation. Interestingly, attempting to build with Unity 6 preview prompts a requirement for NDK version 25.1.8937393, whereas version 2023.2.4f functions seamlessly without such constraints.

    Upon investigating further, Unity specifies support solely for NDK version 23.1.7779620, making it impossible to proceed with an alternate NDK version.

    Error.png

    This problem only occurs on Unity 6.
    Older versions fit.
    As far as I can see from the error, there are two issues.

    The first one is the mismatch of the NDK version.

    The second problem is the absence of compileSdkVersion in the build.gradle file. Even though I've checked that file, everything seems to be in order.

    If anyone has any solution, I would appreciate your advice. I want to stabilize the project in the preview version until the LTS is released.

    Thank you!

    ERROR LOG:


     
    Last edited: May 4, 2024
  2. hytka81

    hytka81

    Joined:
    Jun 22, 2013
    Posts:
    31
    I have been facing Android build issues after upgrading to Unity 6000.0.0f1. I'm using versions installed with Unity.
    First I had compilation error indicating that namespace was missing from build.gradle.

    android {
    namespace "com.your.package.name"
    ...
    }

    After I added it to mainTemplate.gradle I'm now getting:

    [CXX1100] android.ndkVersion is [25.1.8937393] but android.ndkPath C:\Program Files\Unity\Hub\Editor\6000.0.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK refers to a different version [23.1.7779620]

    Any help is appreciated thank you.

    upload_2024-5-4_18-28-13.png
     
  3. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    88
    Hey,

    You should update your templates after switching Unity version.
    Latest MainTemplate.gradle contains enties:
    Code (CSharp):
    1.  
    2. android {
    3.     namespace "com.unity3d.player"
    4.     ndkPath "**NDKPATH**"
    5.     ndkVersion "**NDKVERSION**"
    6.  
    7.     compileSdkVersion **APIVERSION**
    8.     buildToolsVersion '**BUILDTOOLS**'
    9. .
    10. .
    11. .
    So I assume you issue comes from a "conflict" between version of template you have and the latest one
     
    runette_unity likes this.
  4. IndigoGorki

    IndigoGorki

    Joined:
    Mar 2, 2018
    Posts:
    39
    It works, thank you very much!
    I had changed those files before, but it didn't help.

    I probably didn't edit everything that was needed, now it works, thanks a lot for your help and your time!
     
  5. hytka81

    hytka81

    Joined:
    Jun 22, 2013
    Posts:
    31
    Thanks, after re-creating the template(s) I didn't need to edit template myself. But now I'm getting following error which is not directly related to Unity since it's coming from adb.exe but these android tools are shipped with Unity 6.

    I tested running the same adb.exe command using Administrator command prompt and it gives the same error.

    ---
    OS Name Microsoft Windows 11 Enterprise
    Version 10.0.22631 Build 22631
    ---

    CommandInvokationFailure: Please make sure the Android SDK is installed and is properly configured in the Editor. See the Console for more details.
    C:\Program Files\Unity\Hub\Editor\6000.0.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\adb.exe -s "ba421876" shell pm list packages "com.my.package.name"

    stderr[

    Exception occurred while executing 'list':
    java.lang.SecurityException: Shell does not have permission to access user 10
    com.android.server.am.ActivityManagerService.handleIncomingUser:14235 android.app.ActivityManager.handleIncomingUser:4748 com.android.server.pm.PackageManagerShellCommand.translateUserId:3728
    at com.android.server.am.UserController.handleIncomingUser(UserController.java:2710)
    at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:14235)
    at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:4748)
    at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3728)
    at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:1063)
    at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:959)
    at com.android.server.pm.PackageManagerShellCommand.runList(PackageManagerShellCommand.java:792)
    at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:234)
    at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
    at android.os.ShellCommand.exec(ShellCommand.java:38)
    at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:6823)
    at android.os.Binder.shellCommand(Binder.java:1092)
    at android.os.Binder.onTransact(Binder.java:912)
    at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4352)
    at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:6807)
    at android.os.Binder.execTransactInternal(Binder.java:1392)
    at android.os.Binder.execTransact(Binder.java:1299)
    ]
    stdout[

    ]
    exit code: 255
     
  6. IGuscin

    IGuscin

    Unity Technologies

    Joined:
    May 12, 2022
    Posts:
    88
    When do you get that error?
    I'm not sure if anything has changed there recently
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,948
    This is not directly related to Unity, try checking this post - https://android.stackexchange.com/q...on-shell-does-not-have-permission-to-access-u
     
  8. hytka81

    hytka81

    Joined:
    Jun 22, 2013
    Posts:
    31
    Yes, it seems to be related to device and permissions to install/uninstall the APK. Just wondering what happened with version update, since previously I was able to deploy to this particular device just fine. I'm able to deploy to my other Android device and will try to get that other one working too. Thank you.