Closed Shaobin-Jiang closed 1 year ago
I have the same issue too. You can fix it by specifying the ndkVersion within the build.gradle in the generated unity project. However, it will be overriden every time you export the project, so I wrote a command that overrides the generated version with the one that includes the ndkVersion line.
android { ndkVersion = "21.3.6528147" 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"] } } }
I have the same issue too. You can fix it by specifying the ndkVersion within the build.gradle in the generated unity project. However, it will be overriden every time you export the project, so I wrote a command that overrides the generated version with the one that includes the ndkVersion line.
android { ndkVersion = "21.3.6528147" 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"] } } }
That did not exactly work for me @weidenbach , but gave me a hint as to how the problem might be solved. As I have only limited experience with flutter and almost none with vanilla android development, or at least I have never engaged in projects that requires me to look deeper into the project structure, I never realized that there might be more than one build.gradle
file in the project.
In my case, the solution is this: I manually replaced line 69 in android/unityLibrary/build.gradle
, which was originally
commandLineArgs.add("--tool-chain-path=" + android.ndkDirectory)
with the line below:
commandLineArgs.add("--tool-chain-path=" + "C:/Installed/UnityEditor/2022.2.0f1c1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK")
where the path within the quotation marks is where my NDK is installed.
Just ran into the same error while testing a build on Unity 2022.3.4.
This line at the top of the error hints at the solution:
[CXX1100] Both android.ndkPath and ndk.dir in local.properties are set
These newer Unity versions add a ndkPath variable to unityLibrary/build.gradle
android {
+ ndkPath "C:/Program Files/Unity/Hub/Editor/.....
This conflicts with the ndk.dir
in local.properties.
Simply removing ndk.dir from local.properties solved this error for me.
Unity version: 2022.2.0f1c1 on Windows 11
android/local.properties
Where the above ndk path is what I directly copied from Unity's preference settings.
Despite having done this, after using
Flutter run
, I keep receiving the error below:This is kind of frustrating, since I have done exactly what the instructions from the README dictates. Is there anything I can do to solve this?