Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidOperationException: The build cannot be appended. #234

Open
e1engineer opened this issue Oct 25, 2020 · 20 comments
Open

InvalidOperationException: The build cannot be appended. #234

e1engineer opened this issue Oct 25, 2020 · 20 comments

Comments

@e1engineer
Copy link

I'm trying to create a simple Unity project accessible in Flutter.

But when trying to export using the Flutter Unity Package (https://github.com/juicycleff/flutter-unity-view-widget/tree/master/scripts/FlutterUnityPackage.unitypackage), I receive the following error:

"InvalidOperationException: The build cannot be appended."

Steps to reproduce:

Unity Hub > New > 3D > Create > Click to open new project > Import Flutter Unity Package > Flutter > Export iOS

"InvalidOperationException: The build cannot be appended."

This happens on most versions of Unity. Is there something I'm missing here?

Google: No results found for "the build cannot be appended".

Seems to be an issue with the Flutter Unity Package and newer versions of Unity, which are required for my project.

@e1engineer
Copy link
Author

I suppose this works on Unity version 2019.4.3f1. I will see if I can make an exception. Although on 2019.4.3f1, the following warning appears:

"iOS project doesn't seem to exist, can't append, using replace mode."

@Darkmax
Copy link

Darkmax commented Oct 25, 2020

I'm also having this issue in windows for android, using unity 2019.4.13f1 and 2020.1.10f1, it shows the following error when click Export Android

InvalidOperationException: The build target does not support build appending. UnityEditor.BuildPipeline.BuildPlayer (System.String[] scenes, System.String locationPathName, System.String assetBundleManifestPath, UnityEditor.BuildTargetGroup buildTargetGroup, UnityEditor.BuildTarget target, UnityEditor.BuildOptions options, System.String[] extraScriptingDefines) (at <3037c1046402403280ab8b0782ca806f>:0)

Update: it seems an error with the last versions 20201.10f1 and 2019.4.13f1, because I tried with the previous version of unity 2019.4.12f1 and is working correctly

@noodle1983
Copy link

noodle1983 commented Nov 1, 2020

The AcceptExternalModificationsToPlayer option seems to be redefined?
Some more codes is added to unity 2019.4.13f1. Though it is not published, the decompilation of UnityEditor.dll shows

if ((options & BuildOptions.AcceptExternalModificationsToPlayer) == BuildOptions.AcceptExternalModificationsToPlayer)
{
  switch (InternalEditorUtility.BuildCanBeAppended(target, locationPathName))
  {
    case CanAppendBuild.Unsupported:
      throw new InvalidOperationException("The build target does not support build appending.");
    case CanAppendBuild.No:
      throw new InvalidOperationException("The build cannot be appended.");
  }
}

The removal of AcceptExternalModificationsToPlayer will make it happy.

@snlehton
Copy link

Our build pipeline broke down too when upgrading to 2019.4.14f1. Unity has changed the behaviour of BuildOptions.AcceptExternalModificationsToPlayer. It no longer works with Gradle builds. You have to use EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

https://forum.unity.com/threads/oculus-build-invalidoperationexception-the-build-target-does-not-support-build-appending.994930/

@midoshawky
Copy link

Our build pipeline broke down too when upgrading to 2019.4.14f1. Unity has changed the behaviour of BuildOptions.AcceptExternalModificationsToPlayer. It no longer works with Gradle builds. You have to use EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

https://forum.unity.com/threads/oculus-build-invalidoperationexception-the-build-target-does-not-support-build-appending.994930/

thanks for him i just opened Build.cs file and edited it : changed doBuild function of the android target
looking for this line
var options = BuildOptions.AllowDebugging.AcceptExternalModificationsToPlayer;
and change it to something else like that
var options = BuildOptions.AllowDebugging;
and it worked

@pyciko
Copy link

pyciko commented Nov 12, 2020

Having exactly the same issue on 2020.1.10f1 (android export)

@Darkmax
Copy link

Darkmax commented Nov 12, 2020

Having exactly the same issue on 2020.1.10f1 (android export)

@pyciko did you try the solution that mention @midoshawky ?

@pyciko
Copy link

pyciko commented Nov 12, 2020

Having exactly the same issue on 2020.1.10f1 (android export)

@pyciko did you try the solution that mention @midoshawky ?

yes I did
the result was useless too. it managed to build the apk, but then, a couple of errors came out in unity, and even more errors on build with flutter. sorry, not around my pc right now, but I can send them later

@supremematador1
Copy link

Hi,

I tried @midoshawky solution and it let me build the APK, I use the oculus quest to recieve data from external sensors via bluetooth, however, when I delete the BuildOptions.AcceptExternalModificationsToPlayer option the oculus quest no longer recieves sensor data and I can no longer build the app without removing this option. EditorUserBuildSettings.exportAsGoogleAndroidProject = true; doesn't fix my issue, it only let's me build the app.
Does anyone have a similar issue?

@pyciko
Copy link

pyciko commented Nov 13, 2020

Yeah so, @Darkmax, about the problems.
If I change the line of code that @midoshawky suggested, it builds the apk, but nothing more. UnityExport folder is missing, unity as library is missing etc.

@juicycleff
Copy link
Owner

@emcengineer is this an Oculus specific build issue?

@russelljahn
Copy link

russelljahn commented Nov 29, 2020

Thanks @snlehton and @midoshawky, your solutions worked for me to resolve this error on Android/iOS builds in Unity 2020.1.15f1.

To summarize, replace the following lines in Assets > FlutterUnityIntegration > Editor > Build.cs.

For iOS, replace this line in DoBuildIOS() -
var options = BuildOptions.AcceptExternalModificationsToPlayer;
with
var options = BuildOptions.AllowDebugging;

For Android, replace this line in DoBuildAndroid() -
var options = BuildOptions.AcceptExternalModificationsToPlayer;
with
var options = BuildOptions.AllowDebugging;
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

On Android, that last line is important. It tells Unity to export an Android Studio project instead of an apk. Forgetting it will cause the copy step of the export script to fail.

@ghost
Copy link

ghost commented Nov 30, 2020

@russelljahn Do you mean DoBuildIOS for iOS?
By the way, when I build, where exactly can I find the unity project? I looked at Builds directory and all I see is a Test Project.apk directory which seems to be my Android build directory. However, I can't find the iOS build directory. On the readme it says that they are in android/unityLibrary and ios/UnityLibrary but where are those directories?

@russelljahn
Copy link

@aznshodan Yep, typo, I meant DoBuildIOS for iOS.

And yes, those are the correct directories. When exported successfully, they're located under your root Flutter project folder:

<Your Flutter Project>
├── android
│   └── unityLibrary
├── ios
│   └── UnityLibrary
├── lib
├── test
├── unity 
│   └── <Your Unity Project>
│       ├── Assets
│       └── Builds
├── pubspec.yml
├── README.md

@russelljahn
Copy link

For example, in my screenshots molecule is my Flutter project directory.

The exported unityLibrary location for Android:

Android export location

The exported UnityLibrary location for iOS:

iOS export location

@AltairBarahona
Copy link

Our build pipeline broke down too when upgrading to 2019.4.14f1. Unity has changed the behaviour of BuildOptions.AcceptExternalModificationsToPlayer. It no longer works with Gradle builds. You have to use EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
https://forum.unity.com/threads/oculus-build-invalidoperationexception-the-build-target-does-not-support-build-appending.994930/

thanks for him i just opened Build.cs file and edited it : changed doBuild function of the android target
looking for this line
var options = BuildOptions.AllowDebugging.AcceptExternalModificationsToPlayer;
and change it to something else like that
var options = BuildOptions.AllowDebugging;
and it worked

I love you, it works

@adam-fu
Copy link

adam-fu commented Sep 24, 2021

I had the same issue when building Andorid projec on ubuntut with unity engine 2020.3.19f1 using FlutterUnityIntegration-v4.1.0. i will try other combinations to see what works

@kafiarifin
Copy link

kafiarifin commented Oct 9, 2021

Our build pipeline broke down too when upgrading to 2019.4.14f1. Unity has changed the behaviour of BuildOptions.AcceptExternalModificationsToPlayer. It no longer works with Gradle builds. You have to use EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
https://forum.unity.com/threads/oculus-build-invalidoperationexception-the-build-target-does-not-support-build-appending.994930/

thanks for him i just opened Build.cs file and edited it : changed doBuild function of the android target looking for this line var options = BuildOptions.AllowDebugging.AcceptExternalModificationsToPlayer; and change it to something else like that var options = BuildOptions.AllowDebugging; and it worked

my issue has been solved, with this solution. thanks brother @midoshawky

Unity version 2020.3.20f1
Flutter Unity Integration v4.1.0 : https://github.com/juicycleff/flutter-unity-view-widget/blob/master/scripts/FlutterUnityIntegration-v4.1.0.unitypackage

@kjyv
Copy link

kjyv commented May 18, 2022

@juicycleff Can this fix be merged anytime soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests