使用 Visual Studio 2019 编译 Android apk 的发布步骤

问题描述 投票:0回答:4

我使用 Visual Studio 2019 - 跨平台 Xamarin C# 完成了我的第一个应用程序。该应用程序运行良好。现在,我想将其编译为apk文件,以便我可以手动将其安装到手机上。 我确实将调试更改为发布,然后右键单击 android 文件并选择存档。 但是,出现如下错误:

The preprocessor token 'rootnamespace' has been given more than one value. Choosing 'Calculator.Droid' as the value.
The preprocessor token 'assemblyname' has been given more than one value. Choosing 'Calculator.Android' as the value.
The preprocessor token 'fullpath' has been given more than one value. Choosing 'D:\Calculator\Calculator\Calculator.Android' as the value.
The preprocessor token 'outputfilename' has been given more than one value. Choosing 'Calculator.Android.dll' as the value.
The preprocessor token 'filename' has been given more than one value. Choosing 'Calculator.Android.csproj' as the value.
MSB4094: "obj\Release\81\Calculator.Android.dll;obj\Release\81\Calculator.Android.dll" is an invalid value for the "OutputAssembly" parameter of the "Csc" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".
xamarin compilation apk release
4个回答
1
投票

我遇到了同样的错误,只需在项目属性中设置应用程序图标即可解决它。

考虑到错误,这没有多大意义,但它对我有用。希望这对某人有帮助。


1
投票

对我来说,这是由项目属性中错误的“Android Package Signing”数据引起的。修复后就消失了


0
投票

首先尝试了 VV Voon 解决方案,确实它有助于制作 apk 文件,但使链接到未增加的文件大小为 23mb 至 67mb。但后来改为仅SDK程序集,并将Dex编译器更改为DX,以前是空白的。现在我的 apk 大小又回到了 23mb。


0
投票

就我而言,android-project 的 .csproj 中缺少以下条目: 仅 SDK

在 VisualStudio 2019 中,我将 android 选项中的链接器属性从 SdkOnly 更改为 None,然后又更改回 SdkOnly,并且警告消失了,因为该条目已创建。

© www.soinside.com 2019 - 2024. All rights reserved.