Skip to content

Commit 29a3809

Browse files
authored
Move troubleshooting down, below examples.
1 parent 75af10c commit 29a3809

File tree

1 file changed

+141
-138
lines changed

1 file changed

+141
-138
lines changed

README.md

+141-138
Original file line numberDiff line numberDiff line change
@@ -380,144 +380,6 @@ Thanks to [@PiotrxKolasinski](https://github.com/PiotrxKolasinski) for writing d
380380
4. Use the method `SendMessageToFlutter` to send a string. Receive this message using the `onUnityMessage` callback of a `UnityWidget`.
381381

382382

383-
## Troubleshooting
384-
385-
**Location:** Unity
386-
387-
**Error:**
388-
389-
```
390-
Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included on the current platform. Only one assembly with the same name is allowed per platform. (Assets/FlutterUnityIntegration/JsonDotNet/Assemblies/AOT/Newtonsoft.Json.dll)
391-
392-
PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included on the current platform. Only one assembly with the same name is allowed per platform.
393-
```
394-
395-
**Solution:**
396-
Locate the listed dll file, in this case:
397-
`Assets/FlutterUnityIntegration/JsonDotNet/Assemblies/AOT/Newtonsoft.Json.dll`
398-
399-
- Option 1:
400-
Delete the dll file or rename the file extension (e.g. `.dll.txt`) to stop it from being imported.
401-
- Option 2:
402-
Uninstall the package that conflicts in the Unity package manager (usually Version control, or Collab).
403-
The exact package can be found by looking for newtonsoft in `package-lock.json`
404-
405-
---
406-
407-
408-
**Location:** Unity
409-
410-
**Error:**
411-
412-
```
413-
The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
414-
The type or namespace name 'JObject' could not be found (are you missing a using directive or an assembly reference?)
415-
The type or namespace name 'JToken' could not be found (are you missing a using directive or an assembly reference?)
416-
The type or namespace name 'JToken' could not be found (are you missing a using directive or an assembly reference?)
417-
```
418-
419-
**Solution:**
420-
421-
Include the Newtonsoft JsonDotNet library.
422-
It is likely already included in your project with a wrong file extension:
423-
`Assets/FlutterUnityIntegration/JsonDotNet/Assemblies/AOT/Newtonsoft.Json.dll.txt`
424-
Rename the `.dll.txt` extension to `.dll` in your file explorer and open Unity again.
425-
426-
Alternatively you can manually add [the library](https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.1/manual/index.html) from the Unity package manager.
427-
428-
---
429-
430-
431-
**Location:** Unity
432-
433-
**Error:**
434-
435-
```
436-
InvalidOperationException: The build target does not support build appending.
437-
```
438-
439-
**Solution:**
440-
441-
1. Open the *unity/__project-name__/Assets/FlutterUnityIntegration/Editor/Build.cs* file.
442-
443-
1.1. On line 48, change the following:
444-
445-
```diff
446-
- var options = BuildOptions.AcceptExternalModificationsToPlayer;
447-
+ var options = BuildOptions.AllowDebugging;
448-
+ EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
449-
```
450-
451-
1.2. On line 115, change the following:
452-
453-
```diff
454-
- var options = BuildOptions.AcceptExternalModificationsToPlayer;
455-
+ var options = BuildOptions.AllowDebugging;
456-
```
457-
458-
---
459-
460-
**Location:** Android Studio
461-
462-
**Error:**
463-
464-
```
465-
minSdkVersion XX cannot be smaller than version 19 declared in library
466-
\ [:flutter_unity_widget] .../AndroidManifest.xml as the library might be using
467-
\ APIs not available in XX
468-
```
469-
470-
**Solution:**
471-
472-
1. Open the *android/app/build.gradle* file and change the following:
473-
474-
```diff
475-
- minSdkVersion XX
476-
+ minSdkVersion 19
477-
```
478-
479-
---
480-
481-
**Location**: Android Studio
482-
483-
**Error:**
484-
485-
```
486-
e: .../FlutterUnityWidgetBuilder.kt: (15, 42): Expecting a parameter declaration
487-
e: .../FlutterUnityWidgetBuilder.kt: (23, 25): Expecting an argument
488-
e: .../FlutterUnityWidgetController.kt: (22, 44): Expecting a parameter declaration
489-
e: .../FlutterUnityWidgetFactory.kt: (13, 58): Expecting a parameter declaration
490-
```
491-
492-
**Solution:**
493-
494-
1. Open the *android/build.gradle* file and change the following:
495-
496-
```diff
497-
- ext.kotlin_version = '1.3.50'
498-
+ ext.kotlin_version = '1.4.31'
499-
```
500-
501-
---
502-
503-
**Location:** Android Studio
504-
505-
**Error:**
506-
507-
```
508-
Unable to find a matching variant of project :unityLibrary:
509-
```
510-
511-
**Solution:**
512-
513-
1. Open the *android/app/build.gradle* file and change the following:
514-
515-
```diff
516-
lintOptions {
517-
disable 'InvalidPackage'
518-
+ checkReleaseBuilds false
519-
}
520-
```
521383

522384

523385
## Examples
@@ -704,6 +566,147 @@ class _MyAppState extends State<MyApp> {
704566
- `onUnityUnloaded()` (Unity to flutter listener when unity is unloaded)
705567
- `onUnitySceneLoaded(String name, int buildIndex, bool isLoaded, bool isValid,)` (Unity to flutter binding and listener when new scene is loaded)
706568

569+
## Troubleshooting
570+
571+
**Location:** Unity
572+
573+
**Error:**
574+
575+
```
576+
Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included on the current platform. Only one assembly with the same name is allowed per platform. (Assets/FlutterUnityIntegration/JsonDotNet/Assemblies/AOT/Newtonsoft.Json.dll)
577+
578+
PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included on the current platform. Only one assembly with the same name is allowed per platform.
579+
```
580+
581+
**Solution:**
582+
Locate the listed dll file, in this case:
583+
`Assets/FlutterUnityIntegration/JsonDotNet/Assemblies/AOT/Newtonsoft.Json.dll`
584+
585+
- Option 1:
586+
Delete the dll file or rename the file extension (e.g. `.dll.txt`) to stop it from being imported.
587+
- Option 2:
588+
Uninstall the package that conflicts in the Unity package manager (usually Version control, or Collab).
589+
The exact package can be found by looking for newtonsoft in `package-lock.json`
590+
591+
---
592+
593+
594+
**Location:** Unity
595+
596+
**Error:**
597+
598+
```
599+
The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
600+
The type or namespace name 'JObject' could not be found (are you missing a using directive or an assembly reference?)
601+
The type or namespace name 'JToken' could not be found (are you missing a using directive or an assembly reference?)
602+
The type or namespace name 'JToken' could not be found (are you missing a using directive or an assembly reference?)
603+
```
604+
605+
**Solution:**
606+
607+
Include the Newtonsoft JsonDotNet library.
608+
It is likely already included in your project with a wrong file extension:
609+
`Assets/FlutterUnityIntegration/JsonDotNet/Assemblies/AOT/Newtonsoft.Json.dll.txt`
610+
Rename the `.dll.txt` extension to `.dll` in your file explorer and open Unity again.
611+
612+
Alternatively you can manually add [the library](https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.1/manual/index.html) from the Unity package manager.
613+
614+
---
615+
616+
617+
**Location:** Unity
618+
619+
**Error:**
620+
621+
```
622+
InvalidOperationException: The build target does not support build appending.
623+
```
624+
625+
**Solution:**
626+
627+
1. Open the *unity/__project-name__/Assets/FlutterUnityIntegration/Editor/Build.cs* file.
628+
629+
1.1. On line 48, change the following:
630+
631+
```diff
632+
- var options = BuildOptions.AcceptExternalModificationsToPlayer;
633+
+ var options = BuildOptions.AllowDebugging;
634+
+ EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
635+
```
636+
637+
1.2. On line 115, change the following:
638+
639+
```diff
640+
- var options = BuildOptions.AcceptExternalModificationsToPlayer;
641+
+ var options = BuildOptions.AllowDebugging;
642+
```
643+
644+
---
645+
646+
**Location:** Android Studio
647+
648+
**Error:**
649+
650+
```
651+
minSdkVersion XX cannot be smaller than version 19 declared in library
652+
\ [:flutter_unity_widget] .../AndroidManifest.xml as the library might be using
653+
\ APIs not available in XX
654+
```
655+
656+
**Solution:**
657+
658+
1. Open the *android/app/build.gradle* file and change the following:
659+
660+
```diff
661+
- minSdkVersion XX
662+
+ minSdkVersion 19
663+
```
664+
665+
---
666+
667+
**Location**: Android Studio
668+
669+
**Error:**
670+
671+
```
672+
e: .../FlutterUnityWidgetBuilder.kt: (15, 42): Expecting a parameter declaration
673+
e: .../FlutterUnityWidgetBuilder.kt: (23, 25): Expecting an argument
674+
e: .../FlutterUnityWidgetController.kt: (22, 44): Expecting a parameter declaration
675+
e: .../FlutterUnityWidgetFactory.kt: (13, 58): Expecting a parameter declaration
676+
```
677+
678+
**Solution:**
679+
680+
1. Open the *android/build.gradle* file and change the following:
681+
682+
```diff
683+
- ext.kotlin_version = '1.3.50'
684+
+ ext.kotlin_version = '1.4.31'
685+
```
686+
687+
---
688+
689+
**Location:** Android Studio
690+
691+
**Error:**
692+
693+
```
694+
Unable to find a matching variant of project :unityLibrary:
695+
```
696+
697+
**Solution:**
698+
699+
1. Open the *android/app/build.gradle* file and change the following:
700+
701+
```diff
702+
lintOptions {
703+
disable 'InvalidPackage'
704+
+ checkReleaseBuilds false
705+
}
706+
```
707+
708+
709+
707710
## Flavors
708711

709712
### Recommendation

0 commit comments

Comments
 (0)