【问题标题】:Step of Release compile Android apk using Visual Studio 2019发布步骤使用 Visual Studio 2019 编译 Android apk
【发布时间】:2019-09-24 04:19:06
【问题描述】:

我使用 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".

【问题讨论】:

  • 您的.csproj 中是否有多个条目用于根命名空间、程序集名称等...?
  • 我怎么知道有多个条目?成功运行我的程序后,我没有碰任何东西。之后,我只是更改为发布并单击存档。
  • 如果改成release模式,android默认链接器设置为SDK Assemblies Only,可以参考这个链接docs.microsoft.com/en-us/xamarin/android/deploy-test/…
  • 嗨,我解决了这个问题,它是有效的,我得到了 apk。 :D。无论如何,我将链接更改为无,它是有效的。
  • @LeonLu 嗨,它不起作用。我将链接更改为无,它的工作原理。

标签: xamarin compilation apk release


【解决方案1】:

对我来说,这是由项目属性中错误的“Android 包签名”数据引起的。修好后就没了

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-07
      • 1970-01-01
      • 1970-01-01
      • 2021-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多