Getting a build error in Unity3d when building a VR project - android

I am trying to build a sample project which can be found at this link https://www.coursera.org/learn/xr-introduction/supplement/cARor/project-work-build-a-vr-application-to-your-device and I am getting this error:
Build completed with a result of 'Failed'
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00242] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:194
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:97
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
What to do?

Try to build in a different location? Preferably outside your project folder.

Related

Mono.AndroidTools.AdbException: Attempted to read past the end of the stream (on visual studio)

I am building an APP using Xamarin / Visual studio for Mac
I have already a project on an Mac mini.
And now I moved that project to an new iMac.
Compile is good. But when trying deploy to a physical device. It got error
"Mono.AndroidTools.AdbException: Attempted to read past the end of the stream"
If I create a new project on the new iMac. It can deploy to the device.
But my old project can't.
Here is some log. I am now stuck at here....Thank you!
80% ... 32128kb of 40140kb copied
90% ... 36160kb of 40140kb copied
100% ... 40140kb of 40140kb copied
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): warning ADB1000: Failed to delete package file: One or more errors occurred. (One or more errors occurred. (One or more errors occurred. (device '9f5f1695' not found)))
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: Deployment failed
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: Mono.AndroidTools.AdbException: Attempted to read past the end of the stream. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Mono.AndroidTools.Util.ReadFullAsyncResult.EndRead (System.IAsyncResult ar) [0x00024] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Util/StreamExtensions.cs:95
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Mono.AndroidTools.Adb.AdbSyncClient.FileWrite_OnReadStatus (System.IAsyncResult ar) [0x0000c] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbSyncClient.cs:619
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: --- End of inner exception stack trace ---
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError (System.Threading.CancellationToken token) [0x0002a] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Util/AggregateAsyncResult.cs:72
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Mono.AndroidTools.Adb.AdbSyncClient.EndPush (System.IAsyncResult result) [0x00006] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbSyncClient.cs:771
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs:534
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: --- End of stack trace from previous location where exception was thrown ---
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x0008f] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:180
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x003ce] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:203
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at AndroidDeviceExtensions.InstallSharedRuntimeAsync (Mono.AndroidTools.AndroidDevice device, System.String runtimeFile, Mono.AndroidTools.Adb.AdbProgressReporter progress, System.Threading.CancellationToken token) [0x000ac] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:433
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at AndroidDeviceExtensions.InstallSharedRuntimeAsync (Mono.AndroidTools.AndroidDevice device, System.Boolean provideFullDebugRuntime, System.Threading.CancellationToken cancellationToken, Xamarin.AndroidTools.IProgressNotifier progressReporter) [0x000ac] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:630
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Xamarin.AndroidTools.AndroidDeploySession.CheckAndInstallSharedRuntimeAsync () [0x0009c] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:321
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Xamarin.AndroidTools.AndroidDeploySession.EnsureCorrectSharedRuntimes () [0x000f2] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:258
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x001f9] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:198
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:123
To resolve issue on my Mac I had to type
adb uninstall Mono.Android.DebugRuntime
sometimes when this bug happens adb was disconnecting from device, and had to type also
adb kill-server
UPDATE:
Another apps would sometimes gave me similar error and uninstalling Mono.Android.DebugRuntime didn't help.
I ran out of ideas and factory reset of my macbook did the trick. No more problems with installing app on devices. Sometimes fresh start is the best way :)
I am using Visual Studio 2022, Windows 10,
Having the same error message, changing USB port or USB cable doesn't work,
Run commands doesn't work:
adb uninstall Mono.Android.DebugRuntime
adb kill-server
But restarting the computer WORKS!
This was fixed by reboot the Mac....

Xamarin.Android APK Deployment failed - INSTALL_FAILED_INVALID_APK base.apk code is missing

My Xamarin.Android app can no longer be deployed to an emulator/device. I can compile it successfully and the deployment process is started but in the end it fails. I'm using Visual Studio for Mac and Xamarin.Android:
[INSTALL_FAILED_INVALID_APK: Package couldn't be installed in
/data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==: Package
/data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==/base.apk code is
missing]
My build configuration is below:
Multi-dex = ON because without it I'm getting the DEX size error
DEX compiler = DX (D8 doesn't work, I'm getting a compilation error that some classes are missing, see below)
Code shrinker = Off (this is a debug build to run on local emulator/device)
This error occurs if I set DEX compiler to D8:
R8 : warning : Missing class: androidx.appcompat.widget.AppCompatEditText (and 10 more similar errors)
missing R8 : error : Compilation can't be completed because some library classes are missing.
The error occurs with all the settings above, this is basically the only configuration I can build my app but unable to deploy it to device:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: Deployment failed
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==: Package /data/app/my.app.bundle.id-agudyKm4Ib_8OheG3_5zmg==/base.apk code is missing]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess (System.String output, System.String packageName) [0x00152] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:341
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Mono.AndroidTools.AndroidDevice+<>c__DisplayClass95_0.<InstallPackage>b__0 (System.Threading.Tasks.Task`1[TResult] t) [0x00016] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AndroidDevice.cs:753
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at System.Threading.Tasks.ContinuationTaskFromResultTask`1[TAntecedentResult].InnerInvoke () [0x00024] in <f9d1b832704f410aa8ec771f4fe80552>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: --- End of stack trace from previous location where exception was thrown ---
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x00189] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:187
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x003df] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:203
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Xamarin.AndroidTools.AndroidDeploySession.InstallPackage () [0x003be] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:433
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x003ae] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:217
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(612,2): error ADB0010: at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/runner/runners/2.165.0/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:119
Not a Xamarin expert but if you can see the native files, can you check gradle.properties if it has:
android.useAndroidX=true
android.enableJetifier=true
Also inside the build.gradle of the native files (app directory) you should have:
implementation "androidx.appcompat:appcompat:1.1.0"
Unfortunately the I wasn't able to make it work with DEX Compiler = DX, and when you switch to D8, the migration to AndroidX is required. In terms of Xamarin, you have to add the following package and all additional requested dependencies:
<PackageReference Include="Xamarin.AndroidX.AppCompat">
<Version>1.1.0</Version>
</PackageReference>
Another issue I hit was the usage of old packages.config file which have to be migrated to the project PackageReference. This is not supported from Visual Studio for Mac so you have to switch to Windows to accomplish that tasks. A lot of extra steps just to compile an application in support.

Errors while trying to build Unity app for VR

When I build or "build and run" the project I get three main errors. The project works because when I press play it does what it suppose to do in the game window. I'm trying to develop for the gearVr and Oculus which I selected in project settings.
I've looked at unity preferences made sure its using the correct SDK, JDK and NDK I even tried using the recommended settings but still couldn't upload anything to my device.
ERROR 1
CommandInvokationFailure: Gradle build failed. C:\Program
Files\Unity\Hub\Editor\2019.1.2f1\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe
-classpath "C:\Program Files\Unity\Hub\Editor\2019.1.2f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar"
org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m"
"assembleRelease"
stderr[
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':packageRelease'.
org.gradle.tooling.BuildException (no error message) ...
ERROR 2
Build completed with a result of 'Failed' 0x00007FF6E6F9104C (Unity)
StackWalker::GetCurrentCallstack 0x00007FF6E6F94501 (Unity)
StackWalker::ShowCallstack 0x00007FF6E56FDCC5 (Unity) GetStacktrace
0x00007FF6E79AF1D0 (Unity) DebugStringToFile 0x00007FF6E6FBFB49
(Unity) DebugLogHandler_CUSTOM_Internal_Log 0x00000200025704EB (Mono
JIT Code) (wrapper managed-to-native)
UnityEngine.DebugLogHandler:Internal_Log
(UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
...
ERROR 3
UnityEditor.BuildPlayerWindow+BuildMethodException: 53 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer
(UnityEditor.BuildPlayerOptions options) [0x00242] in
C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:194
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean
askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions)
[0x0007f] in
C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:97
0x00007FF6E6F9104C (Unity) StackWalker::GetCurrentCallstack
0x00007FF6E6F94501 (Unity) StackWalker::ShowCallstack
0x00007FF6E56FDCC5 (Unity) GetStacktrace 0x00007FF6E79AF1D0 (Unity)
DebugStringToFile 0x00007FF6E6FBFB49 (Unity)
DebugLogHandler_CUSTOM_Internal_Log 0x00000200025704EB (Mono JIT Code)
(wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log
(UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
0x00000200025703AB (Mono JIT Code) [DebugLogHandler.cs:10]
UnityEngine.DebugLogHandler:LogFormat
(UnityEngine.LogType,UnityEngine.Object,string,object[])
0x0000020002564691 (Mono JIT Code) [Logger.cs:61]
UnityEngine.Logger:Log (UnityEngine.LogType,object)
0x000002000257E7ED (Mono JIT Code) [Debug.bindings.cs:127]
UnityEngine.Debug:LogError (object) 0x0000020039D5E5E3 (Mono JIT
Code) [BuildPlayerWindowBuildMethods.cs:103]
UnityEditor.BuildPlayerWindow:CallBuildMethods
(bool,UnityEditor.BuildOptions) 0x0000020039D377FB (Mono JIT Code)
[BuildPlayerWindow.cs:908]
UnityEditor.BuildPlayerWindow:GUIBuildButtons
(UnityEditor.Modules.IBuildWindowExtension,bool,bool,bool,UnityEditor.Build.BuildPlatform)
Normally the apk will be uploaded to my phone asking me to place the device into the GearVR.
There seems to be a problem with Gradle. As a workaround you could try to switch from "gradle" to "internal" in the Build Window.

The "ConvertResourcesCases" task failed unexpectedly. Xamarin Android build

When I build my Xamarin Android app with Visual Studio 2017 for Mac(7.7.4 build 1), Mono JIT compiler version 5.18.0.248 (2018-08/a4956c837e1 Fri Jan 25 16:13:12 EST 2019) I get the following exceptions:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: The "ConvertResourcesCases" task failed unexpectedly.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: System.IO.IOException: Could not create file "/Users/username/Companymobil/src/Company.Recipes.Droid/obj/Debug/lp/35/jl/res/values-ca/values-ca.xml" or "/var/folders/b5/821mhz8n0px17rnxglrjq5mc0000gp/T/tmp565e9644.tmp". File already exists.
/var/folders/b5/821mhz8n0px17rnxglrjq5mc0000gp/T/
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00193] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/File.cs:111
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (Microsoft.Build.Framework.ITaskItem item, System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x00204] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x0000f] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.Execute () [0x000a7] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: The "ConvertResourcesCases" task failed unexpectedly.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: System.IO.IOException: Could not create file "/Users/username/Companymobil/src/Company.ServerAnnouncement.Droid/obj/Debug/lp/15/jl/res/layout/notification_template_icon_group.xml" or "/var/folders/b5/821mhz8n0px17rnxglrjq5mc0000gp/T/tmp4d4475a7.tmp". File already exists.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00193] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/File.cs:111
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (Microsoft.Build.Framework.ITaskItem item, System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x00204] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.FixupResources (System.Collections.Generic.Dictionary`2[TKey,TValue] acwMap) [0x0000f] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Xamarin.Android.Tasks.ConvertResourcesCases.Execute () [0x000a7] in <78f051a6e2064f849cc3ee585300af39>:0
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1689,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784
If I click on Build (NOT Rebuild) those exceptions get less every time I build until it finally builds successfully.
If I use jetbrains Rider, the build works every single time.
I gave full permissions (r/w) to everyone on the directories mentioned in the exception and I still get the error. I use APFS case-insensitive.
I would be very grateful for any pointer to solve this.
Thank you very much Leon Lu from Microsoft for pointing me in the right direction. The error stems from a condition in parallel building xamarin android. When parallel builds are disabled, the outcome is the same each time. Parallel builds can be disabled in the Preferences of Visual Studio 2017 for Mac (see attached image).
The issue seems to be fixed (see GitHub link in Leon Lu's comment) and be rolling out in one of the future updates.

Untiy 2017.2.0f3: cant build android apk error: CommandInvokationFailure: Failed to sign APK package

I am trying to build a test for my app. When i build the app i get the following error
CommandInvokationFailure: Failed to sign APK package.
C:\Program Files (x86)\Android\android-sdk\build-tools\26.0.2\apksigner.bat sign --ks "D:/Programming/UnityProjects/MobileProject-resortTycoon/user.keystore" --ks-pass stdin --ks-key-alias "test123" --key-pass stdin "D:\Programming\UnityProjects\MobileProject-resortTycoon\Temp/StagingArea/Package.apk"
stderr[
Error: keywords 'java|openjdk version' not found in 'picked up java_tool_options: -df'
Error: keywords 'java|openjdk version' not found in 'picked up java_tool_options: -df'
Failed to load signer "signer #1"
java.io.IOException: Invalid keystore format
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:658)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:56)
at sun.security.provider.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:224)
at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(JavaKeyStore.java:70)
at java.security.KeyStore.load(KeyStore.java:1445)
at com.android.apksigner.ApkSignerTool$SignerParams.loadKeyStoreFromFile(ApkSignerTool.java:829)
at com.android.apksigner.ApkSignerTool$SignerParams.loadPrivateKeyAndCertsFromKeyStore(ApkSignerTool.java:719)
at com.android.apksigner.ApkSignerTool$SignerParams.loadPrivateKeyAndCerts(ApkSignerTool.java:659)
at com.android.apksigner.ApkSignerTool$SignerParams.access$500(ApkSignerTool.java:611)
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:266)
at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:89)
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Keystore password for signer #1:
]
exit code: 2
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.RunWithStdin (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg, System.String[] input)
UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg, System.String[] stdin)
UnityEditor.Android.PostProcessor.Tasks.BuildAPK.SignPackage (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.Tasks.BuildAPK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I already tried reinstalling the Android SDK and updating it to latest version, downloading a different android versions, using the new gradle instead of internal. Nothing worked. After 2 days of searching for a solution I still dont know how to fix this. Can someone help me? Thanks alot!
There seems to be a problem with your keystore and not the sdk. I don't know if you know what a keystore is, so here you go:
A keystore is a file that acts like a "password" for your app. Google play for example will not let you update your app unless the update is signed with the same keystore as your app. Whatever you do, do not lose the keystore after you publish your app.
If you have not jet generated a keystore for your app you can generate one in unity: https://forum.unity.com/threads/android-signing.62137/
If you already have a keystore it most likely got corrupted somehow. If you already published your app somewhere I hope you have a backup. If not just generate a new keystore
I dont know why but I was able to fix my problem. When I installed Java JDK, it installed 2 folders. Unity automatically selected 1 folder called "jdk-9". When I changed it to "jdk1.8.0_131" I was able to build my app.
If any knows why this works, I will be happy to know!

Categories

Resources