Closed nyck33 closed 1 year ago
- git clone the repo
- open the example folder in Android studio
- open a terminal and type flutter run
You are missing a vital step.
2.1. open example\unity\DemoApp
in Unity3D
2.2. Click Flutter -> Export Android ( .. )
in Unity and wait for the process to complete.
The error is that there is no project in android\unityLibrary
, which gets generated by Unity.
@timbotimbo thanks, I watched the video and read the Readme, almost had it running but it launched on the web browser so of course nothing worked.
This time I am getting some gradle and java compatibility error perhaps because I did this:
In the Reedme it says, put the fuw-xxxx.unitypackage
in the unity/appname folder which I did.
I guess I only need to do that if it's my own project and not the example project in this repo.
My exact gradle java error is:
nyck33@nyck33-IdeaPad-Gaming-3-15ACH6:~/Documents/flutter/flutter-unity-view-widget/example$ flutter run
Launching lib/main.dart on A202ZT in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file '/home/nyck33/Documents/flutter/flutter-unity-view-widget/example/android/settings.gradle' (/home/nyck33/.gradle/caches/6.5/scripts/25aorcp10u58z2dyk7lm4qet/settings6418c6d726070f323dbddda2aadc82ef).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61
* 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 2s
Running Gradle task 'assembleDebug'... 3.2s
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────┐
│ [!] Your project's Gradle version is incompatible with the Java version that Flutter │
│ is using for Gradle. │
│ │
│ To fix this issue, first, check the Java version used by Flutter by running `flutter │
│ doctor --verbose`. │
│ │
│ Then, update the Gradle version specified in │
│ /home/nyck33/Documents/flutter/flutter-unity-view-widget/example/android/gradle/wrap │
│ per/gradle-wrapper.properties to be compatible with that Java version. See the link │
│ below for more information on compatible Java/Gradle versions: │
│ https://docs.gradle.org/current/userguide/compatibility.html#java │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
Should I start over? I've started over like 5 times now.
I noticed some differences like I don't get a Unity-Exports folder at all. I do right click on the unity-classes.jar and get the following directory tree
I am also guessing that because I am using Android Studio Flamingo, which is using jdk 17 and not 11, that's the problem. I'll look into switching that as well.
Please ignore the video, that should be removed from the readme, since its ancient.
I've managed to build my own project using Flamingo without issues, the switch to java 17 didn't seem to break it.
The example project has some old gradle versions so I'll need to check if something is incompatible there.
Got it, thanks, I'll try again. I'm on Ubuntu 22.04 (not WSL) but my Unity is on Windows so I boot out do the Unity stuff then come back to Ubuntu on dual boot and do my Flutter stuff just in case that is causing problems.
I believe that an android export from Unity on mac and windows are incompatible when moved to the other platform. Although that could also be because of arm vs x64 processors.
So it wouldn't surprise me if moving a windows export to ubuntu might cause issues.
Sadly the Unity export on Ubuntu in general seems to be broken too, look for the 'linux' tag in these issues.
I see, so I have to stay in Windows it sounds like end to end. Not even WSL2 am I correct? Ie. I have to install Flutter on Windows and not WSL2.
What about this step, do I need to perform it for the example app in this repo?
Copy the fuw-XXXX.unitypackage file into the Unity project folder. The expected path is unity/project-name/fuw-XXXX.unitypackage
You don't need the unitypackage if you are using the example Unity project. The unitypackage is basically the FlutterUnityIntegration folder in the example project.
Thanks! I'll give it another shot here.
A few more hideous errors but nailed it down to
* What went wrong:
Execution failed for task ':unityLibrary:BuildIl2CppTask'.
> NDK is not installed
so I tried this https://stackoverflow.com/questions/66603488/ndk-is-not-installed
so my local.properties is like
sdk.dir=C:\\Users\\nycki_gq3buqc\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\software\\flutter
flutter.buildMode=debug
ndk.dir=C:\Program Files\Android\Android Studio\plugins\android-ndk\lib
but that's not working either.
Can you try adding the Unity NDK? (edit to match your exact unity version)
For windows you'll need \\
instead of \
// mac
ndk.dir=/Applications/Unity/Hub/Editor/2020.3.19f1/PlaybackEngines/AndroidPlayer/NDK
// windows
ndk.dir=C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.13f1\\Editor\\Data\\PlaybackEngines\\AndroidPlayer\\NDK
This was added to the readme, but for some reason not under Android Setup but a separate NDK section.
Everything works now, thanks! Except Native Activity Demo
Another exception was thrown: Could not find a generator for route
RouteSettings("/activity", null) in the _WidgetsAppState.
D/VelocityTracker(32111): addMovement: actionMasked:1, mChangeDirection:0, set it true
Another exception was thrown: Could not find a generator for route
RouteSettings("/activity", null) in the _WidgetsAppState.
Hello, I ran into this exact error and tried what's written on this thread. It's still not working. Here is list of the things I tried:
Describe the bug
To Reproduce Steps to reproduce the behavior: