Forms (Android) archiving error "an item with the same key has already been added"

johnm0101johnm0101 Member ✭✭
edited May 2 in Xamarin.Forms

My project builds OK. the iOs version is fully uploaded but when I try to archive the latest version of the Android app it gives the above error
There are numerous references to the phrase "an item with the same key" but none relevant to the archiving process
I have tried going through all nuget packages, cleaning the project, rebuilding.
Some posts which are not necessarilly relevant to Archiving suggest it might be a nuget package - I have checked all versions are necessary and latest
Indeed nothing has changed (apart from my code) since the last successful archive
I did see a reference that the 'version' number should not be decimal - mine is not and I have been very careful to ensure it has been incremented
I dont know where I can find out more about this Archiving error or what is causing it

Any suggestions gratefully received

Answers

  • AnubhavRanjanAnubhavRanjan INXamarin Team Xamurai
    edited May 2

    @johnm0101 Can you create a blank app and see if you are seeing the same error when archiving it twice?
    Although the said error should not happen when archiving with different version numbers.
    I just tried it and didn't get any error even though I didn't update the version number.
    Can you try and delete the bin folder?

    .

    .

    .



    Looking for Free* Microsoft Support on Xamarin Issues, visit https://aka.ms/xamarinsupport


  • johnm0101johnm0101 Member ✭✭
    edited May 2

    @AnubhavRanjan what a lovely man for trying to answer my conundrum;-) Many tx

    well I tried another app - I had several attempts to build it as it is a bit of a tesbed - but no !
    same problem
    "another item with the same key has already been added"
    I have tried on both to delete the bin and the obj folders
    tried cleaning tried restarting machine
    oh yes and I tried deleting all the archives inthe solution

    FYI I am working on VS2019 preview 16.1 preview 2

    Also may be relevant - the main app I am trying to publish seems to take an age to compile - ovenight and still not finished - had to break and restart - usually rebooting, cleaning and deleting bin/obj restores the build speed to something sensible but could this be the cause of the archiving problem?
    What "item" is the message referring to and where are the keys kept?
    I have followed the Xamarin instructions for publishing to playstore and indeed I have managed to upload about 5 previous versions. Is there a manual way of resetting what VS thinks is the case?>

    PS: just noticed one more thing which might be relevant - on the archive screen it goes to do the archiving before it fails - I notice that there is no version number showing - whereas previous archives all show the correct version number

  • johnm0101johnm0101 Member ✭✭

    AHA!!!!! I think I've got it
    I was first, building the whole solution - this obviously created and added an android package to wherever VS secretes away such stuff
    I then tried changing the version number ( I am sure it has something to do with that) then instead of building the solution or even just building the android app I went straight to archive (of course it builds before it archives when you do that)
    By doing that it went through without a hitch

    strange behaviour though - I mean you'd normally build the solution for release - shove the iOS ipa over to the and upload it with the xcode application loader then return to use the more usable Android archiving process
    but this sequence does not work - got to archive android first

  • AnubhavRanjanAnubhavRanjan INXamarin Team Xamurai

    @johnm0101 Glad to hear that you finally worked it through to your EndGame ;)

    .

    .

    .

    .



    Looking for Free* Microsoft Support on Xamarin Issues, visit https://aka.ms/xamarinsupport


  • johnm0101johnm0101 Member ✭✭

    Spoke too soon - this 'workaround' is no longer working for me
    I've tried deleting the obj and bin folders for android and the solution, incremented the version no. (am running out of numbrs ;-) _- then folowed the process I described above - I am still getting the error 'an item with the same key...'
    Does anyoone know what this 'key' is and where it is stored so I can delete it ???

    (I've tried deleting all the archives both from within VS2019 and through file explorer
    I'm on win10 and 2019 latest preview Btw)

  • JarvanJarvan Member, Xamarin Team Xamurai

    what this 'key' is

    Refer to: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/manually-signing-the-apk#create-a-private-keystore

    where it is stored

    For Win: C:\Users\USERNAME\AppData\Local\Xamarin\Mono for Android\debug.keystore
    For Mac: ~/.local/share/Xamarin/Mono for Android/debug.keystore
    Refer to: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/keystore-signature?tabs=windows#for-debug--non-custom-signed-builds

  • johnm0101johnm0101 Member ✭✭

    Hmm I thought it might be some other 'key'
    Well I do understand about debug.keystores and release keystores. Surely I dont have to have a different release keystore for every build? That is the implication of this error message.
    The process for using the Xamarin archive wizard is to set the Android build to release but unsigned.
    It seems the build goes through as the first step after starting the archive wizard. The keysore I created for release is added at a later stage. The error message comes before the step at which one selects the keystore - Thats why I dont understand whats going on - as far as I can see the android app is first buil without a key then packed and then the key added (or have I got that wrong?)
    Why is it saying something with the same key is preventing archiving when the build is set to build with no signing?(as per Xamarin istructions)
    The documentation does not help understanding an error which is specific to the VS2019 archiving wizard for Android.

  • JarvanJarvan Member, Xamarin Team Xamurai

    @johnm0101
    Tools > Options > Xamarin > Archives Location
    If the path does not ends with a \ it fails to archive. Just add a \ at the end.

    Similar issue here: https://github.com/xamarin/xamarin-android/issues/3063

  • johnm0101johnm0101 Member ✭✭

    many tx @yelinzh
    my archive location did indeed not end in "\"
    however still got same result - "an item with same key ......"
    as with others in the github posts which you kindly referenced - but it does look like the same issue
    will try more fiddling around

Sign In or Register to comment.