flutter-unity-view-widget
flutter-unity-view-widget copied to clipboard
FAILURE: Build failed with an exception
Describe the bug Hi friends I'm trying to build an app in flutter with flutter-unity-view-widget but I get the error: FAILURE: Build failed with an exception.
*Any idea why? Can you please guide me on how to fix it?
- OS: OS Name Microsoft Windows 11 Pro Version 10.0.22000 Build 22000
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [Version 10.0.22000.434], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
X Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.63.2)
[√] Connected device (2 available)
Expected behavior FAILURE: Build failed with an exception.
-
Where: Build file 'C:\Users\burac\Documents\FlutterProjects\uni_unity\unity_playground\android\unityLibrary\build.gradle' line: 35
-
What went wrong: A problem occurred evaluating project ':unityLibrary'.
Could not get unknown property 'unityStreamingAssets' for object of type com.android.build.gradle.internal.dsl.AaptOptions.
-
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
-
Get more help at https://help.gradle.org
BUILD FAILED in 1s Exception: Gradle task assembleDebug failed with exit code 1 Exited (sigterm)
build.gradle' line: 35 : noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
from: aaptOptions { noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ') ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!.scc:.:!CVS:!thumbs.db:!picasa.ini:!~" }
Add that to your gradle.properties in your android studio project:
unityStreamingAssets=.unity3d, google-services-desktop.json, google-services.json, GoogleService-Info.plist
Or whatever value is that in your unity project. Check your setting.gradle in your unity project
Hi @johnfriedrich thanks for your suggestion and help, I did that and now I get:
`Launching lib\main.dart on Android SDK built for x86 in debug mode... lib\main.dart:1 Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Note: C:\Users\burac\Documents\FlutterProjects\uni_unity\unity_playground\android\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Location specified by ndk.dir (C:Program FilesUnityHubEditor2020.3.26f1EditorDataPlaybackEnginesAndroidPlayerNDK) did not contain a valid NDK and and couldn't be used
FAILURE: Build failed with an exception.
-
Where: Build file 'C:\Users\burac\Documents\FlutterProjects\uni_unity\unity_playground\android\unityLibrary\build.gradle' line: 63
-
What went wrong: Execution failed for task ':unityLibrary:BuildIl2CppTask'.
Location specified by ndk.dir (C:Program FilesUnityHubEditor2020.3.26f1EditorDataPlaybackEnginesAndroidPlayerNDK) did not contain a valid NDK and and couldn't be used
`
Any ideas on how to fix this? Thanks in advance!
The error is telling you what to do. I suggest reading the readme. Keep in mind that
C:Program FilesUnityHubEditor2020.3.26f1EditorDataPlaybackEnginesAndroidPlayerNDK
is in no way a valid path. Also x86 mode is not supported. Test on a real device
Thanks again @johnfriedrich ,
I read the Docs 100 times :P now, I updated the NDK version and the path was wrong if you insert it directly from Unity like:
ndk.dir=C:\Program Files\Unity\Hub\Editor\2020.3.26f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK -> is wrong
I replaced it with:
ndk.dir=C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.26f1\\Editor\\Data\\PlaybackEngines\\AndroidPlayer\\NDK
Now I managed to build it, but I still get these warnings:
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Thanks a lot for your support!
P.S: @johnfriedrich do you know how to load a specific scene from the Unity game in Flutter? Thanks!
These warning are fine, you can ignore them.
You would need to use the Messaging system. Like sending a message to a gameobject/script in your scene which then loads a scene
Closing this as the issue seems resolved.