Open RoxDevvv opened 2 years ago
You replace all content on BuildIl2Cpp function by these:
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("--enable-debugger")
//commandLineArgs.add("--profiler-report")
//commandLineArgs.add("--profiler-output-file=" + workingDir + "/build/il2cpp_"+ abi + "_" + configuration + "/il2cpp_conv.traceevents")
commandLineArgs.add("--print-command-line")
commandLineArgs.add("--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/external/bdwgc/include")
commandLineArgs.add("--additional-include-directories=" + workingDir + "/src/main/Il2CppOutputProject/IL2CPP/libil2cpp/include")
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")
and add path to unity ndk tool in android/local.properties, example:
ndk.dir=/Applications/Unity/Hub/Editor/2021.2.13f1/PlaybackEngines/AndroidPlayer/NDK
Hope this helps. Origin solution: https://github.com/juicycleff/flutter-unity-view-widget/issues/544
Try to export unity to apk first. During the process you will probably fail and get some error prompts which tell you where the problems are. Then try to export to project, just make sure android and unityLibrary refer the same ndk folder.
Describe the bug while trying to build in flutter
FAILURE: Build failed with an exception.
Where: Build file 'E:\Project\Flutter\auto\signlanguage\android\unityLibrary\build.gradle' line: 59
What went wrong: Execution failed for task ':unityLibrary:BuildIl2CppTask'. Process 'command 'E:/Project/Flutter/auto/signlanguage/android/unityLibrary/src/main/Il2CppOutputProject/IL2CPP/build/deploy/netcoreapp3.1/il2cpp.exe'' finished with non-zero exit value 4
Gardle file:
this is my gardle file : i did not edit it , it is auto generated so i don't know why it give error