Could not start '/**/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp'

Hey everyone,

I have recently exported Google Cardboard VR enabled Android project from Unity with scripting backend set to IL2CPP.

When building the Android project, I encountered the following exception, looks like it cannot locate the il2cpp executable at all. I have double checked that ndk and sdk were set correctly and under Il2CppOutputProject folder, it only has IL2CPP/ and Source/ folder.

Unity version: 2021.3.8f1
Android Studio version: Android Chipmunk

> Task :unityLibrary:BuildIl2CppTask FAILED

Execution failed for task ':unityLibrary:BuildIl2CppTask'.
> A problem occurred starting process 'command '/**/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp''

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':unityLibrary:BuildIl2CppTask'.
 at  org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/**/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp''
    at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:241)
    at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:218)
    at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:372)
    at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:87)
    at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
    ... 3 more
Caused by: net.rubygrapefruit.platform.NativeException: Could not start '/**/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp'
    at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
    at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
    at org.gradle.process.internal.ExecHandleRunner.startProcess(ExecHandleRunner.java:98)
    at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:71)
    ... 4 more
Caused by: java.io.IOException: Cannot run program "/**/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp" (in directory "/**/unityLibrary"): error=2, No such file or directory
    at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
    ... 7 more
Caused by: java.io.IOException: error=2, No such file or directory
    ... 8 more

I got stuck on building the app, Any suggestions or experiences with this type of error?

Thanks!

Found out the problem is caused by build.gradle has executable workingDir + “/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp” path which can not be found. It should be pointing to executable “/Applications/Unity/Hub/Editor/2021.3.8f1/Unity.app/Contents/il2cpp/build/deploy/il2cpp”

"/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp" should exist, are there any files in /src/main/Il2CppOutputProject/IL2CPP/build/deploy/ folder?

hello having the same issue… the solution by jianinz did work, I want to dig a bit more on the problem, I exported in a windows pc, and I’m making the android build in a Mac… could this be related? and if so this is a new change because I’ve been doing this with other unity versions and it did work…

Without knowing Unity version which you use - hard to tell, but yes it’s expected that you build gradle project on the same host where the export happened. Since when you export from windows, only windows il2cpp executable is copied, which is not usable on OSX

Hi I’m facing the same issue, when I’m trying a build a react native unity integrated project over CI/CD, could you suggest some solution for the same?
I’m using unity version 2022.2.1f1
PFA my build.gradle file in UnityLibrary

apply plugin: ‘com.android.library’

dependencies {
implementation fileTree(dir: ‘libs’, include: [‘*.jar’])
implementation(name: ‘arcore_client’, ext:‘aar’)
implementation(name: ‘UnityARCore’, ext:‘aar’)
implementation(name: ‘ARPresto’, ext:‘aar’)
implementation(name: ‘unityandroidpermissions’, ext:‘aar’)

}

android {
// ndkPath “C:/Program Files/Unity 2022.2.1f1/2022.2.1f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK”
ndkPath “/home/runner/work/Hashedin-Relay/Hashedin-Relay/AR_Food_Menu/Frontend/android/android-ndk-r23b”

compileSdkVersion 32
buildToolsVersion ‘32.0.0’
ndkVersion ‘23.1.7779620’

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

defaultConfig {
minSdkVersion 26
targetSdkVersion 32
ndk {
abiFilters ‘armeabi-v7a’, ‘arm64-v8a’
}
versionCode 1
versionName ‘0.1’
consumerProguardFiles ‘proguard-unity.txt’
}

lintOptions {
abortOnError false
}

aaptOptions {
noCompress = [‘.unity3d’, ‘.ress’, ‘.resource’, ‘.obb’, ‘.bundle’, ‘.unityexp’] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = “!.svn:!.git:!.ds_store:!.scc:!CVS:!thumbs.db:!picasa.ini:!~”
}

packagingOptions {
doNotStrip ‘/armeabi-v7a/.so’
doNotStrip ‘/arm64-v8a/.so’
}
}

def getSdkDir() {
Properties local = new Properties()
local.load(new FileInputStream(“${rootDir}/local.properties”))
return local.getProperty(‘sdk.dir’)
}

def BuildIl2Cpp(String workingDir, String configuration, String architecture, String abi, String[ ] staticLibraries) {
def commandLineArgs = [ ]
commandLineArgs.add(“–compile-cpp”)
commandLineArgs.add(“–platform=Android”)
commandLineArgs.add(“–architecture=” + architecture)
commandLineArgs.add(“–outputpath=” + workingDir + “/src/main/jniLibs/” + abi + “/libil2cpp.so”)
commandLineArgs.add(“–libil2cpp-static”)
commandLineArgs.add(“–baselib-directory=” + workingDir + “/src/main/jniStaticLibs/” + abi)
commandLineArgs.add(“–incremental-g-c-time-slice=3”)
commandLineArgs.add(“–configuration=” + configuration)
commandLineArgs.add(“–dotnetprofile=unityaot-linux”)
commandLineArgs.add(“–profiler-report”)
commandLineArgs.add(“–profiler-output-file=” + workingDir + “/build/il2cpp_”+ abi + “" + configuration + “/il2cpp_conv.traceevents”)
commandLineArgs.add(“–print-command-line”)
commandLineArgs.add(“–data-folder=” + workingDir + “/src/main/Il2CppOutputProject/Source/il2cppOutput/data”)
commandLineArgs.add(“–generatedcppdir=” + workingDir + “/src/main/Il2CppOutputProject/Source/il2cppOutput”)
commandLineArgs.add(“–cachedirectory=” + workingDir + "/build/il2cpp
”+ abi + “_” + configuration + “/il2cpp_cache”)
commandLineArgs.add(“–tool-chain-path=” + android.ndkDirectory)
staticLibraries.eachWithIndex {fileName, i->
commandLineArgs.add(“–additional-libraries=” + workingDir + “/src/main/jniStaticLibs/” + abi + “/” + fileName)
}
def executableExtension = “”
if (org.gradle.internal.os.OperatingSystem.current().isWindows())
executableExtension = “.exe”
exec {
executable workingDir + “/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp” + executableExtension
args commandLineArgs
environment “ANDROID_SDK_ROOT”, getSdkDir()
}
delete workingDir + “/src/main/jniLibs/” + abi + “/libil2cpp.sym.so”
ant.move(file: workingDir + “/src/main/jniLibs/” + abi + “/libil2cpp.dbg.so”, tofile: workingDir + “/symbols/” + abi + “/libil2cpp.so”)
}

android {
task BuildIl2CppTask {
doLast {
BuildIl2Cpp(projectDir.toString().replaceAll(‘\\’, ‘/’), ‘Release’, ‘armv7’, ‘armeabi-v7a’, as String[ ]);
BuildIl2Cpp(projectDir.toString().replaceAll(‘\\’, ‘/’), ‘Release’, ‘arm64’, ‘arm64-v8a’, as String[ ]);
}
}
afterEvaluate {
if (project(‘:unityLibrary’).tasks.findByName(‘mergeDebugJniLibFolders’))
project(‘:unityLibrary’).mergeDebugJniLibFolders.dependsOn BuildIl2CppTask
if (project(‘:unityLibrary’).tasks.findByName(‘mergeReleaseJniLibFolders’))
project(‘:unityLibrary’).mergeReleaseJniLibFolders.dependsOn BuildIl2CppTask
}
sourceSets {
main {
jni.srcDirs = [“src/main/Il2CppOutputProject”]
}
}
}

The solution was already posted for the issue above

Found out the problem is caused by build.gradle has executable workingDir + “/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp” path which can not be found. It should be pointing to executable “/Applications/Unity/Hub/Editor/2021.3.8f1/Unity.app/Contents/il2cpp/build/deploy/il2cpp”

I believe this solution is for a local build, but i want to ask the same for GitHub CI/CD pipeline build. Could you please recommend something?

what does 'executable workingDir + “/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp”’ point to? Is there no il2cpp executable there?

so it has a il2cpp.exe (*.exe being windows executable file format), but i guess since we’re working on Ubuntu OS on our CI/CD pipeline, it might be looking for *.elf (Ubuntu’s executable file format).

On the same lines, we’re not able to find a way to be able to export our unity game as an android project, that generates il2cpp.elf file (ubuntu file format file) on this location (“executable workingDir + "/src/main/Il2CppOutputProject/IL2CPP/build/deploy/il2cpp”). FYI, we’re using a windows machine

8750040--1185477--upload_2023-1-23_15-6-14.png

Why not have Linux Unity Editor, and export gradle project from there?


I tried opening the project as linux editor, but it generates a *.exe file on export. How do we open a Linux editor on a windows machine?

Since you’re trying to build gradle project in linux, you need to produce gradle project on linux too by using linux unity editor

but how do we access linux unity editor in windows?

You can’t access linux editor on windows, you need to install linux editor on linux

I am running into the same issue as you. Did you resolve the problem? And if so, how?

I have also encountered the same problem. I would like to ask how do you solve this problem? What is the solution

The workaround is to use the same host type for both building from Unity and building the gradle project. As far as I know there are no plans to allow to intermix hosts in this case.