stride3d / stride

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

Android Resource error #553

Open sognatore99 opened 4 years ago

sognatore99 commented 4 years ago

Xenko Version 3.1.0.1 Using Physics Sample and opening in Visual Studio 2019 Xamarin. When I compile (either Debug or Release) for Android I am receiving this error:

Severity Code Description Project File Line Suppression State Suppression State Error CS0433 The type 'Resource' exists in both 'Xenko.Engine, Version=3.1.0.1, Culture=neutral, PublicKeyToken=null' and 'Xenko, Version=3.1.0.1, Culture=neutral, PublicKeyToken=null' PhysicsSample.Android C:\Users\xxxx\Documents\Xenko Projects\PhysicsSample\PhysicsSample.Android\Resources\Resource.Designer.cs 29 Active

I am using Visual Studio 2019 Version 16.3.8. I have read that VS 2019 has some issue with resources but I could not load the solution produced in VS 2017 as I get a waring that "the solution is higher than the solution version supported"

Any help would be appreciated. I have done the standard clean, rebuild, restart VS2019, reboot computer, screamed loudly :) etc.

Thanks

WernhervonBraun commented 4 years ago

I have this error on any Android project. Even empty.

RodrigoMedeirosRS commented 4 years ago

Any workaround to this error? Same problem here.

RodrigoMedeirosRS commented 4 years ago

Error

yangguosdxl commented 4 years ago

This Error is caused by auto generate Resource.Designer.cs.

Xenko.Engine.csproj's RootNamespace is Xenko, so it's namespace is Xenko in generated Resource.Designer.cs. this namespace is the same as Xenko.csproj's Resource.Designer.cs

I change the RootNamespace property to Xenko.Engine in project Xenko.Engine, it generate the Resource class to Xenko.Engine. This fix the namesapce conflict error. but cause another error “d:\home\workspace\test\XenkoSrc\build\xenko.build”(BuildAndroidXenkoEngine target) (1) -> “d:\home\workspace\test\XenkoSrc\sources\engine\Xenko.Engine\Xenko.Engine.csproj”(Build target) (2) -> “d:\home\workspace\test\XenkoSrc\sources\engine\Xenko.Engine\Xenko.Engine.csproj”(Build target) (2:5) -> (CoreCompile target) -> Starter\AndroidXenkoActivity.cs(134,82): error CS0117: '“Resource” no “Layout” define [d:\home\workspace\test\XenkoSrc\sources\engine\Xenko.Engine\Xenko.Engine.csproj] Starter\AndroidXenkoActivity.cs(136,81): error CS0117: '“Resource”未包含“Id”的定义 [d:\home\workspace\test\XenkoSrc\sources\engine\Xenko.Engine\Xenko.Engine.csproj] Starter\AndroidXenkoActivity.cs(143,41): error CS0117: '“Resource”未包含“Layout”的定义 [d:\home\workspace\test\XenkoSrc\sources\engine\Xenko.Engine\Xenko.Engine.csproj] Starter\AndroidXenkoActivity.cs(144,68): error CS0117: '“Resource”未包含“Id”的定义 [d:\home\workspace\test\XenkoSrc\sources\engine\Xenko.Engine\Xenko.Engine.csproj] Starter\AndroidXenkoActivity.cs(151,98): error CS0117: '“Resource”未包含“Id”的定义 [d:\home\workspace\test\XenkoSrc\sources\engine\Xenko.Engine\Xenko.Engine.csproj]

But I don't understand why emit this error

Basewq commented 4 years ago

For anyone on version 3.1.0.1 (ie. official release), try this workaround: Edit your [GAMENAME].Android.csproj file in Notepad (or any text editor). Add the following at the end, but still inside <Project> </Project>:

<Project ....>
  [OTHER STUFF]

  <Target Name="AddCustomAliases" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
    <ItemGroup>
      <ReferencePath Condition="'%(FileName)' == 'Xenko' AND '%(ReferencePath.NuGetPackageId)' == 'Xenko'">
        <Aliases>XenkoFull</Aliases>
      </ReferencePath>
    </ItemGroup>
  </Target>
</Project>

Note this will (hopefully) not be needed in the next official release, as yangguosdxl has pushed a proper fix for this issue.

ghost commented 3 years ago

With the current 4.0.0 version it still gives this error, when will it be fixed?