Search Unity

Bug Error Message: > NDK is not installed See the Console for Details <

Discussion in 'Editor & General Support' started by Westbang, Mar 29, 2023.

  1. Westbang

    Westbang

    Joined:
    May 25, 2020
    Posts:
    4
    I got often the Error

    NDK is not installed See the Console for Details

    Unity Error-1.jpg

    when I chose

    Build And Run

    to create my Android App.



    I use Unity Version 2022.2.12



    With previous Unity Versions this Error comes not up.



    Console Log Error:

    Code (JavaScript):
    1.  
    2.  
    3. stderr[
    4. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    5.  
    6. FAILURE: Build failed with an exception.
    7.  
    8. * Where:
    9. Build file 'D:\Unity Projekte\apk\Terra-Combat-2023.aab\unityLibrary\build.gradle' line: 71
    10.  
    11. * What went wrong:
    12. Execution failed for task ':unityLibrary:BuildIl2CppTask'.
    13. > NDK is not installed
    14.  
    15.  

    Build.gradle :


    Code (JavaScript):
    1. apply plugin: 'com.android.library'
    2.  
    3.  
    4. dependencies {
    5.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    6.     implementation 'androidx.appcompat:appcompat:1.0.0'
    7.     implementation 'com.google.android.gms:play-services-vision:15.0.2'
    8.     implementation 'com.google.android.material:material:1.0.0'
    9.     implementation 'com.google.protobuf:protobuf-javalite:3.10.0'
    10.  
    11.     implementation(name: 'sdk', ext:'aar')
    12.  
    13. }
    14.  
    15. android {
    16.     compileSdkVersion 32
    17.     buildToolsVersion '32.0.0'
    18.  
    19.     compileOptions {
    20.         sourceCompatibility JavaVersion.VERSION_1_8
    21.         targetCompatibility JavaVersion.VERSION_1_8
    22.     }
    23.  
    24.     defaultConfig {
    25.         minSdkVersion 26
    26.         targetSdkVersion 32
    27.         ndk {
    28.             abiFilters 'arm64-v8a'
    29.         }
    30.         versionCode 54
    31.         versionName '4.5'
    32.         consumerProguardFiles 'proguard-unity.txt'
    33.     }
    34.  
    35.     lintOptions {
    36.         abortOnError false
    37.     }
    38.  
    39.     aaptOptions {
    40.         noCompress = ['.unity3d', '.ress', '.resource', '.obb', '.bundle', '.unityexp'] + unityStreamingAssets.tokenize(', ')
    41.         ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    42.     }
    43.  
    44.     packagingOptions {
    45.         doNotStrip '*/arm64-v8a/*.so'
    46.     }
    47. }
    48.  
    49. def getSdkDir() {
    50.     Properties local = new Properties()
    51.     local.load(new FileInputStream("${rootDir}/local.properties"))
    52.     return local.getProperty('sdk.dir')
    53. }
    54.  
    55. def BuildIl2Cpp(String workingDir, String configuration, String architecture, String abi, String[] staticLibraries) {
    56.     def commandLineArgs = []
    57.     commandLineArgs.add("--compile-cpp")
    58.     commandLineArgs.add("--platform=Android")
    59.     commandLineArgs.add("--architecture=" + architecture)
    60.     commandLineArgs.add("--outputpath=" + workingDir + "/src/main/jniLibs/" + abi + "/libil2cpp.so")
    61.     commandLineArgs.add("--libil2cpp-static")
    62.     commandLineArgs.add("--baselib-directory=" + workingDir + "/src/main/jniStaticLibs/" + abi)
    63.     commandLineArgs.add("--configuration=" + configuration)
    64.     commandLineArgs.add("--dotnetprofile=unityaot-linux")
    65.     commandLineArgs.add("--profiler-report")
    66.     commandLineArgs.add("--profiler-output-file=" + workingDir + "/build/il2cpp_"+ abi + "_" + configuration + "/il2cpp_conv.traceevents")
    67.     commandLineArgs.add("--print-command-line")
    68.     commandLineArgs.add("--data-folder=" + workingDir + "/src/main/Il2CppOutputProject/Source/il2cppOutput/data")
    69.     commandLineArgs.add("--generatedcppdir=" + workingDir + "/src/main/Il2CppOutputProject/Source/il2cppOutput")
    70.     commandLineArgs.add("--cachedirectory=" + workingDir + "/build/il2cpp_"+ abi + "_" + configuration + "/il2cpp_cache")
    71.     commandLineArgs.add("--tool-chain-path=" + android.ndkDirectory)
    72.     staticLibraries.eachWithIndex {fileName, i->
    73.         commandLineArgs.add("--additional-libraries=" + workingDir + "/src/main/jniStaticLibs/" + abi + "/" + fileName)
    74.     }
    75.     def executableExtension = ""
    76.     if (org.gradle.internal.os.OperatingSystem.current().isWindows())
    77.         executableExtension = ".exe"
    78.     exec {
    79.         executable workingDir + "/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp" + executableExtension
    80.         args commandLineArgs
    81.         environment "ANDROID_SDK_ROOT", getSdkDir()
    82.     }
    83.     delete workingDir + "/src/main/jniLibs/" + abi + "/libil2cpp.sym.so"
    84.     ant.move(file: workingDir + "/src/main/jniLibs/" + abi + "/libil2cpp.dbg.so", tofile: workingDir + "/symbols/" + abi + "/libil2cpp.so")
    85. }
    86.  
    87. android {
    88.     task BuildIl2CppTask {
    89.         doLast {
    90.               BuildIl2Cpp(projectDir.toString().replaceAll('\\\\', '/'), 'Release', 'arm64', 'arm64-v8a', [  ] as String[]);
    91.         }
    92.     }
    93.     afterEvaluate {
    94.         if (project(':unityLibrary').tasks.findByName('mergeDebugJniLibFolders'))
    95.             project(':unityLibrary').mergeDebugJniLibFolders.dependsOn BuildIl2CppTask
    96.         if (project(':unityLibrary').tasks.findByName('mergeReleaseJniLibFolders'))
    97.             project(':unityLibrary').mergeReleaseJniLibFolders.dependsOn BuildIl2CppTask
    98.     }
    99.     sourceSets {
    100.         main {
    101.             jni.srcDirs = ["src/main/Il2CppOutputProject"]
    102.         }
    103.     }
    104. }

    The Error comes up from Line 71:

    Code (JavaScript):
    1. commandLineArgs.add("--tool-chain-path=" + android.ndkDirectory)

    The Variable:

    Code (JavaScript):
    1. android.ndkDirectory
    delivers not a Vallid result.


    The Settings for the NDK Path are:


    Unity Error-2.jpg



    The strange thing is that for 5 attempts to create the app it works once without this error message.

    I use newest Win 11 Pro Version.


    Unfortunately, the error occurs after 10 minutes because it takes so long to compile.


    The project is currently stopped because I can no longer create the Android app for testing.




    The Error comes also with Version

    2023.1.0b9

    and

    2023.2.0a7

    up.


    Some Time it helps to reboot the Win 11 Computer.



    Regards

    Tom from Germany
     
    Last edited: Mar 29, 2023
  2. Westbang

    Westbang

    Joined:
    May 25, 2020
    Posts:
    4
    I have found out that the problem also occurs on win 10 !
     
    Last edited: Mar 29, 2023
  3. Westbang

    Westbang

    Joined:
    May 25, 2020
    Posts:
    4
    After hours of testing I have solved Problem by adding the Line (in my case):

    Code (JavaScript):
    1. android {
    2.     ndkPath "D:/Unity/Editor/2023.2.0a7/Editor/Data/PlaybackEngines/AndroidPlayer/NDK"
    3. ...
    to my

    mainTemplate.gradle

    File.

    After this the compiling process success.
     
    Last edited: Apr 1, 2023
  4. HotClaw

    HotClaw

    Joined:
    May 20, 2013
    Posts:
    3
    Thanks @Westbang. Your line fixed it for me, but I wanted to find a more generic path to the NDK, so I checked the mainTemplate.gradle file in the .../Editor/Data/PlaybackEngines/AndroidPlayer/Tools/GradleTemplates directory. It includes the below in the
    android
    block:

    Code (JavaScript):
    1. android {
    2.     ndkPath "**NDKPATH**"
    3. }