MonoGame / MonoGame

One framework for creating powerful cross-platform games.
http://www.monogame.net
Other
11.32k stars 2.9k forks source link

Project template "Monogame Android Application (MonoGame Team) produces non compilable project #8349

Closed AndersBillLinden closed 2 months ago

AndersBillLinden commented 3 months ago

Prerequisites

MonoGame Version

MonoGame 3.8.1.303

Which MonoGame platform are you using?

MonoGame Android Application (mgandroid)

Operating System

Windows

Description

When I have created a new project with the template Monogame Android Application (MonoGame Team), the generated code will use the following classes, which are all unresolved:

and some more...

What did I do wrong? I have installed android studio and found Android SDK in

C:\Users\myusername\AppData\Local\Android\Sdk

Which I specify in the user environment variable ANDROID_HOME

The nuget packages that my new project will use are:

Steps to Reproduce

Minimal Example Repo

No response

Expected Behavior

Project be buildable

Resulting Behavior

Project not buildable

Files

No response

AndersBillLinden commented 3 months ago

Am I the only person experiencing this? No reception what so ever on this issue.

tomspilman commented 3 months ago

@SimonDarksideJ @dellis1972 ?

dellis1972 commented 3 months ago

Sounds like the android workload is not installed.

try the following

dotnet workload install android
dellis1972 commented 3 months ago

Also try changing the target framework version in the csproj to net8.0-android (assuming you have .net 8 installed). the current released template tries to use .net 6 which is now out of support. The one in the develop branch has been updated to be .net 8.

AndersBillLinden commented 3 months ago

Sounds like the android workload is not installed.

try the following

dotnet workload install android

Is there some way of having

dotnet workload install android

running if I am trying to create a project with this template and the android workload is not in the system?

AndersBillLinden commented 3 months ago

I installed the android workload and tried to setup the project to use .net8, but still squiggly underlining.

image

image

dellis1972 commented 3 months ago

can you do

dotnet --info
AndersBillLinden commented 3 months ago

can you do

dotnet --info
C:\Windows\System32>dotnet --info
.NET SDK:
 Version:           8.0.204
 Commit:            c338c7548c
 Workload version:  8.0.200-manifests.00e64df5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.204\

.NET workloads installed:
 [android]
   Installation Source: SDK 8.0.200, VS 17.9.34728.123
   Manifest Version:    34.0.113/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.113\WorkloadManifest.json
   Install Type:        FileBased

Host:
  Version:      8.0.6
  Architecture: x64
  Commit:       3b8b000a0e

.NET SDKs installed:
  7.0.410 [C:\Program Files\dotnet\sdk]
  8.0.204 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

C:\Windows\System32>
dellis1972 commented 3 months ago

This is going to sound like a silly questuon but does it build via the command line?

dotnet build

or in the IDE?

What are the "red squiggles" trying to tell you? It is unresolved types? It might be a design time build issue.

dellis1972 commented 3 months ago

At this point it might be worth attaching the template project you are trying to build to the issue so we can take a look

theLaffa commented 2 months ago

Have you tried updating the project to .net 8? With a fresh Android project I get: image

Update androidApp.csproj with <TargetFramework>net8.0-android</TargetFramework> image

Sorry, to note I have the below runtimes installed

.NET SDKs installed:
  6.0.421 [C:\Program Files\dotnet\sdk]
  8.0.204 [C:\Program Files\dotnet\sdk]
  8.0.300 [C:\Program Files\dotnet\sdk]
AndersBillLinden commented 2 months ago

Changing sdk version from 21.0 to 23.0 fixed the build. Strange that I did not get that idea before. Which version is optimal?

SimonDarksideJ commented 2 months ago

We'll make sure the template is updated for the next release.