stride3d / stride

Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
https://stride3d.net
MIT License
6.54k stars 946 forks source link

Cannot create android project #827

Open makemefeelgr8 opened 4 years ago

makemefeelgr8 commented 4 years ago

Release Type: Official Release

Version: 4.0.0.1-beta04-1265

Platform(s): Windows

Describe the bug New project cannot be created.

To Reproduce Steps to reproduce the behavior:

  1. Create a new empty project for .net core 3.1

Expected behavior I expect the project to be created.

Log and callstacks Verbose: Restore NuGet packages for MyGame4.Android... [\MyGame4\MyGame4.Android\MyGame4.Android.csproj(93,3)]: Error: The imported project "C:\Program Files\dotnet\sdk\3.1.302\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.302\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk.

xen2 commented 4 years ago

Does it work better with .NET Framework version of Stride ?

makemefeelgr8 commented 4 years ago

I cannot create .NET Framework android project. The error looks just like this one: https://github.com/stride3d/stride/issues/780 Unfortunately, there is no working way to create an android project. So, the engine is a no-go for me.

laske185 commented 4 years ago

I fixed it temporary for me by removing the MSBuildExtensionsPath variable in the project import of the Xamarin.Android.CSharp.targets.

So I replaced in the *.Android.csproj file <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> by <Import Project="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets" />.

makemefeelgr8 commented 4 years ago

I was able to create a project after applying the workaround you've mentioned. As soon as I launch it, I get the following exception:

'Value cannot be null. Parameter name: path1'

In the Game.Run(GameContext); line.

MrRobJohnson commented 4 years ago

This is the same as I get.

I wish this was being actively developed. It looks such an exciting proposition apposed to Unity but if the tutorial/demo projects can't work out of the box then a lot of users are going to ditch it.

bmello4688 commented 3 years ago

image

bmello4688 commented 3 years ago

From issue #780

Agredo commented 3 years ago

This is still not working? This needs to be fixed. I would love to use it but without this platforms there is no reason to use it.

MeharDT commented 3 years ago

I'm looking into both issues. The Resource.Designer.cs file isn't a requirement for Android projects in Stride/Xenko 3.1 and it actually doesn't generate one for new projects either (only at build). Something changed with 4.0 that now makes this a requirement at project creation.

In the meantime here are two (hopefully temporary) workarounds that will allow you to create working Android projects. This will only work with .NET 4.7.2 projects in Stride 4.0.x as the above issue impacts .NET 5.0 projects.

Workaround 1

Workaround 2

Edit: It seems the Workarounds will apply to .NET 5.0 projects. The only caveat is they won't work with Stride Game Studio (the path errors appear) so you'll need to build through Visual Studio.

MeharDT commented 3 years ago

Sharing my notes in case anyone more familiar with the engine source code has insights. The original issue impacts Android, iOS, and UWP projects and occurs because of how $(MSBuildExtensionsPath) is set in PackageSessionPublicHelper.cs -> ApplyDotNetSdkEnvironmentVariables(). Specifically it points to the dotnet sdk directory instead of the MSBuild folder in the Visual Studio 2019 install directory.

Questions:

  1. Is Visual Studio's MSBuild the intended path for $(MSBuildExtensionsPath) in .Net 5.0 projects and should MSBuildExtensionsPath be updated to reflect this?
  2. If yes, is there a reliable way to determine VS 2019's install location? IMO this would ideally be something that is user configurable in case it's wrong
Jillinger commented 2 years ago

Workaround 1

  • Create a new Android project and wait for the operation to fail due to a missing Resource.Designer.cs file, note the path to your project folder
  • Navigate to the above path and open the .sln file in Visual Studio 2019
  • Build the solution's Android project, this will generate the Resource.Designer.cs file
  • Close Visual Studio and open the project in Stride Game Studio

In trying the first workaround, I am having some problems. I get this error

Error   MSB3644 The reference assemblies for MonoAndroid,Version=v8.1 were not found. 
To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or 
retarget your application. You can download .NET Framework Developer Packs at 
https://aka.ms/msbuild/developerpacks

Of course, this error is not associated with your workaround, but I am wondering, can you offer any suggestions on this? I downloaded NET5.0, and retargeted, but nothing seems to be resolving the error.

xen2 commented 2 years ago

This is fixed in latest master by https://github.com/stride3d/stride/commit/a5a64efca2c127cdf8c9f3ebbc38ecf39f508693

Jillinger commented 2 years ago

Source code? I am not using Stride source code.

xen2 commented 2 years ago

It will be part of next release.