Unity 6 (6000) support.
timbotimbo opened this issue · 37 comments
Description
Unity 2023.1 and 6 (6000.0) include breaking changes for the Android version of this plugin.
And given that 2023.3 turned into 6000, I decided to implement support for Unity 6000.
For a litte more info, see the PR #966
Installing & testing
This alpha version is now live in the experimental/unity_6000 branch.
You can either download it and include the plugin using a relative path
flutter_unity_widget:
path: <folder path>
or include it using the git url
flutter_unity_widget:
git:
url: https://github.com/juicycleff/flutter-unity-view-widget.git
ref: experimental/unity_6000 # branch name
Setup
-
Your Flutter project will need to use Java 17 and gradle 8.x,
Check the example project in the unity_6000 branch for the relevant build.gradle files. -
Set the Unity
Application Entry PointtoActivity.
Player Settings -> Settings for Android -> Other Settings -> Application Entry Point -
After the Unity export,
android/unityLibrary/build.gradlemight include a broken import.- Either fix this automatically by updating your
Assets/FlutterUnityIntegration/Editor/build.csfile with the one from the example project. - Or comment the 2nd line
apply from: '../shared/keepUnitySymbols.gradle'inunityLibrary/build.gradle
- Either fix this automatically by updating your
I'm getting this error when trying to build my flutter application with the export for Android:
Build file '<flutter project>/android/unityLibrary/build.gradle' line: 57
* What went wrong:
A problem occurred evaluating project ':unityLibrary'.
> Could not find method packaging() for arguments [build_e9lpdzw6rpzcgazd3rj2x5k7f$_run_closure2$_closure12@5afe6187] on extension 'android' of type com.android.build.gradle.LibraryExtension.
Coming from this set of lines in the build.grade:
packaging {
jniLibs {
useLegacyPackaging true
}
}
Just tried this again with Unity 6000.0.16 and Flutter 3.24.1.
The example from this repo worked worked without modifications.
(I just had to delete a themeselector line from the androidmanifest)
Then I made a new project using Flutter create, and got your error.
Matching the gradle, AGP and kotlin versions with the example got me past the error.
You likely forgot to upgrade the project to gradle and AGP 8.x.
Using the new gradle apply method used in the latest Flutter versions:
gradle-wrapper.properties
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zipsettings.gradle
- id "com.android.application" version "7.3.0" apply false
- id "org.jetbrains.kotlin.android" version "1.7.10" apply false
+ id "com.android.application" version "8.3.0" apply false
+ id "org.jetbrains.kotlin.android" version "1.9.10" apply falseSeems my reading comprehension was a bit off, thank you for your help, that did fix that issue, and now I have a whole new one, the build works, all the C++ compiles successfully, but I get this error during my build:
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:7:27 Unresolved reference: UnityPlayerActivity
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:11:31 Unresolved reference: UnityPlayerActivity
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:14:5 'onCreate' overrides nothing
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:15:15 Unresolved reference: onCreate
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:17:14 Unresolved reference: window
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:18:22 Unresolved reference: intent
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:25:9 Unresolved reference: mUnityPlayer
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:30:9 Unresolved reference: mUnityPlayer
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:34:22 None of the following functions can be called with the arguments supplied:
public constructor Intent(p0: Context!, p1: Class<*>!) defined in android.content.Intent
public constructor Intent(p0: String!, p1: Uri!) defined in android.content.Intent
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:36:16 Variable expected
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:37:9 Unresolved reference: startActivity
e: file:///<dart-pub-cache>/git/flutter-unity-view-widget-d910dd5904bdbf0eda4a52c31e6f3a66da992f9d/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/OverrideUnityActivity.kt:40:5 'onUnityPlayerUnloaded' overrides nothing
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_unity_widget:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* 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 5m 59s
Error: Gradle task assembleDebug failed with exit code 1
In Unity try Player Settings -> Settings for Android -> Other Settings -> Application Entry Point
Check Activity and not GameActivity.
@timbotimbo That did it! Thank you so much for your help, my application now compiles properly for both iOS and Android. Would it be best if I run into more issues to just reply to this issue, or should I make new issues for other things I run into in the 6000 branch?
Hey @timbotimbo,
Thanks so much for keeping this library alive!
Based on the title 'for Android', does it mean the unity ios build output is unchanged - so unity 6 should work fine, or more like it that would require another PR to add IOS support?
For context:
This version works great for me on android.
On IOS however I'm stuck with a white screen and no output logs in xcode as soon as I include the flutter unity widget as a dependency.
(I also run into the UnityFramework not found issue a lot of ppl brought up in many other issues. Was able to fix that in my build by adding and embedding UnityFramework in the pods target for the flutter unity widget directly and also adding the parent path of the folder to the framework search paths under build settings.)
The only way I could get it running on IOS so far was with a unity 2022 export + master branch.