juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.15k stars 524 forks source link

Error to integrate Unity with Flutter #310

Closed DGMBeebit closed 3 years ago

DGMBeebit commented 3 years ago

Hi, I'm trying to integrate Unity with Flutter but I'm having problems. I am using Unity version 2019.4 and I want to do the integration for a Unity project that has ARFoundation and I'm following the steps in the documentation. But when I export the Unity project, I don't get the (.so) files that I need and when I get the apk, I don't see either. Besides that I know that I have to convert the unity-classes.jar object into a library and Android Studio does not allow me to do that. I attach some screenshots to facilitate understanding of my problem. Thanks a lot.

Captura de pantalla 2021-01-28 a las 9 41 33 Captura de pantalla 2021-01-28 a las 10 01 54
siddarth-bhura commented 3 years ago

I am also facing the same issue. Please help thankyou

gisinator commented 3 years ago

I'm not quite sure whether you really need those files in the libs-folder. I had also been struggling with implementing Unity AR Foundation within Flutter using this plugin, and in the end upgrading Gradle on Android-Studio side was the missing step. I have now a working Unity 2019.4.16f with ARFoundation 2.1.16 integration into AndroidStudio and it works, even without seeing those files in my libs folder:

1) after importing the FlutterUnityPackage-3.0.0.unitypackage, make sure you edit your Build.cs located in "Assets/FlutterUnityIntegration/Editor": Replace this line in DoBuildAndroid() - var options = BuildOptions.AcceptExternalModificationsToPlayer; with var options = BuildOptions.AllowDebugging; EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

2) Dont forget to set minSDK to 24 in both Unity Player Settings as well as in AndroidStudio in "android/app/build.gradle"

3) in my case, I had to upgrade Gradle since I got the "missing package key" error when trying to build in AndroidStudio: edit android/grade/wrapper/gradle-wrapper.properties: distributionUrl = https\://services.gradle.org/distributions/gradle-6.1.1-all.zip edit android/build.gradle: classpath 'com.android.tools.build:gradle:4.0.0'

After all those additional steps, it now works like a charme. Good luck :)