Step of Release compile Android apk using Visual Studio 2019
Asked Answered
T

4

8

I had done my first ever app by using Visual Studio 2019 - cross platform Xamarin C#. The app is running well. Now, I want to compile it to apk file so that I can install it to the mobile phone manually. I did change the debug to release, and then right click from the android file and choose Archive. But, there is an error as below:

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".
Toothpick answered 6/5, 2019 at 13:58 Comment(8)
Do you have multiple entries in your .csproj for rootnamespace, assemblyname, etc...?Biome
How to I know there is multiple entries? I did not touch anything after successfully run my program. After that, I just change to release and click Archive.Toothpick
If you change to release mode, the defaul linker setting is SDK Assemblies Only in android, you could refer to this link.learn.microsoft.com/en-us/xamarin/android/deploy-test/…Jerusalem
Hi, I solved the problem and it is works, i got the apk. :D. Anyway, I change the linking to None, it is works.Toothpick
@VVVoon, do you solved this issue by with the link I provided? Was this issue related to linker? If so , can I post this comment to answer, it will help others who have similair issue.Jerusalem
@LeonLu Hi, it doesn't work. I change the linking to None, it's works.Toothpick
Ok, please post your comment to answer and mark it, it will help others who have similar issue.Jerusalem
I faced similar problem, when i import 2017 solution to 2019 visual studio.. I had just mobile development platform installed when I faced above error.. Later on i tried "try and error" method to install other workloads to wrinkled away this error while building apk.. Some of the linking is with desktop or web development package.. Not have time to pin point which workload solved the problem.Ridgeway
B
1

I encountered this same error and simply setting the Application icon in the project properties solved it.

It doesn't make much sense given the error, but it did the trick for me. Hopefully this helps someone.

Bye answered 16/7, 2019 at 19:40 Comment(0)
E
1

For me it was caused by wrong "Android Package Signing" data in Project Properties. After fixing it went away enter image description here

Elroyels answered 25/7, 2019 at 13:25 Comment(0)
Y
0

Tried VV Voon solution first and indeed it helped to make apk file, but making linking to non increased file size 23mb to 67mb. But later changed to SDK assembly only and changed Dex compiler to DX which was previously blank. Now I got apk size back to 23mb.

Yamashita answered 22/7, 2019 at 7:26 Comment(1)
Removing Application icon from Android Manifest also helped as suggested forums.xamarin.com/discussion/162113/…Yamashita
B
0

In my case in the .csproj of the android-project folling entry was missing: SdkOnly

In VisualStudio 2019 I changed the linker property in the android options from SdkOnly to None and then back to SdkOnly and the warnings were gone because the entry was created.

Biannual answered 25/3, 2024 at 11:10 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.