KeyNotFoundException using Publish Android Application tool from Visual Studio

I am trying to publish my Android app using the Publish Android Application tool from Visual Studio. I am following everything to the letter in the docs.

https://developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_2-_signing_the_android_application_package/

However when I click Publish I am getting the following KeyNotFound Exception.

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
at Xamarin.VisualStudio.Android.Utilities.BuildProject(Project project, String target, IVsOutputWindowPane outputPane, Exception& ex)

I have created the keystore as follows:

keytool -genkey -v -keystore release.keystore -alias mwukreleasekey -keyalg RSA -keysize 2048 -validity 10000

and verified this worked using

keytool -list -keystore release.keystore

Can anyone help me?

Posts

  • jonathanyatesjonathanyates GBMember ✭✭✭

    Also says:

    Unhandled exception in SignPackage. See exception for details.

    More Details

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
    at Xamarin.VisualStudio.Android.Utilities.BuildProject(Project project, String target, IVsOutputWindowPane outputPane, Exception& ex)

  • jonathanyatesjonathanyates GBMember ✭✭✭

    Anyone?

  • jonathanyatesjonathanyates GBMember ✭✭✭
    edited October 2015

    @BrendanZagaeski

    Surely someone else must have had this same issue. I can not for the life of me get this to work. I am trying to publish my app to google play but can not get this signing step to work at all. Please please please can anyone help me?

  • jonathanyatesjonathanyates GBMember ✭✭✭

    I really do need an answer or some help with this as I can not publish my app to goole play.

    Can anyone please help ?

  • jonathanyatesjonathanyates GBMember ✭✭✭
    edited October 2015

    @BrendanZagaeski

    This issue is critical. Has anyone tried to sign a release version recently from Visual Studio. It does not work, therefore we can not deploy Apps!

    Please can someone reply ?

  • jonathanyatesjonathanyates GBMember ✭✭✭

    I take it that either no one cares or no one is actually doing real deployments with Xamarin Android because it does not work.

    I am at the end of my tether because after a years worth of work I can not deploy my app to google play etc because it will not sign it.

    Please please please can someone out there help me??? Please???

  • CodeRinseCodeRinse USMember
    edited October 2015

    Not trying to add salt to the wound, but what version of Xamarin Studio are you using? I found this:

    developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_3-_publishing_an_application_on_google_play/#Publishing_to_Google_Play_Xamarin_Studio_5.9_and_Later

    If you are using pre 5.9 check this link out:

    developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_3-_publishing_an_application_on_google_play/#Uploading_the_APK_pre_Xamarin_Studio_5.9

    Edit:

    Well I re-read and you mentioned you are using Visual Studio. Until we figure out the issue perhaps downloading, installing, and using Xamarin Studio to publish could work for now?

  • jonathanyatesjonathanyates GBMember ✭✭✭

    I am doing this from Visual Studio, not Xamarin Studio. I have other issues with Xamarin Studio which I also need to resolve. I have tried alsorts or things, including moving to a competely different Windows VM. Interestingly I now get this exception:

    Xamarin.Android.XamarinAndroidException: error XA5101: Platform library directory for target Arm and API Level 23 was not found. Expected path is "C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\platforms\android-23\arch-arm\usr\lib"
    at Xamarin.Android.Tasks.NdkUtil.GetNdkPlatformLibPath(String androidNdkPath, AndroidTargetArch arch, Int32 level)
    at Xamarin.Android.Tasks.Aot.DoExecute()
    at Xamarin.Android.Tasks.Aot.Execute()

    C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\platforms\android-23\ does not exist as it suggests. Anyone any ideas?

  • jonathanyatesjonathanyates GBMember ✭✭✭

    Well I seem to have found the cause.

    https://forums.xamarin.com/discussion/49180/android-xa5101-platform-library-directory-for-target-arm-and-api-level-23-was-not-found

    Turning off LLVM works!

    No idea if this is related to the original KeyNotFoundException but it seems to work now.

    Only taken me 3 days of pain to resolve!

  • jonathanyatesjonathanyates GBMember ✭✭✭

    So, wanting to have LLVM turned on I decided to resolve all my Xamarin Studio issues, of which there were many (I will not go into that). But I got everything working sweet on XS regarding builds etc. So, I decide to try the XS route and select 'Archive for Publishing' with LLVM turned on. I was hopeful. Alas, I get the following error:

    error XA3001: Xamarin.Android.XamarinAndroidException: error XA5101: Platform library directory for target Arm and API Level 23 was not found. Expected path is "/Users/jonathanyates/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/platforms/android-23/arch-arm/usr/lib"
    at Xamarin.Android.Diagnostic.Error (Int32 code, System.String message, System.Object[] args) [0x00000] in :0
    at Xamarin.Android.Tasks.NdkUtil.GetNdkPlatformLibPath (System.String androidNdkPath, AndroidTargetArch arch, Int32 level) [0x00000] in :0
    at Xamarin.Android.Tasks.Aot.DoExecute () [0x00000] in :0
    at Xamarin.Android.Tasks.Aot.Execute () [0x00000] in :0
    Task "Aot" execution -- FAILED

    and yet again android-23 is missing. Only showing up to android-21.

    I'm sure I'm not the only one experiencing these issues. Anyone else come across this?

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited October 2015

    (Thanks for the heads-up on this forum thread via the "Business & Enterprise Support" email channel. Emails to the support team and bug reports are the best way to ensure that potential bugs are seen by the Xamarin engineering teams.)


    Ah ha! It looks like both of these are actually AOT build errors rather than signing issues. The "KeyNotFound" exception name is just a horribly unfortunate coincidence because the exception happens when attempting to access a C# dictionary key. In theory you would see these same errors even when using the debug keystore, for example if you attempted to deploy to device or emulator using the same build configuration that you're using for publishing. (You could also hit the same error just by building the project if you switched DefaultTargets="Build" to DefaultTargets="SignAndroidPackage" by editing the text of the .csproj file. See also "Xamarin.Android Build Targets.")

    The original error from the first post in the thread looks like it could be a bug in AOT/LLVM support that would be specific to your project. If by chance you might be able to provide a test case that demonstrates that problem, the Xamarin.Android team would be interested to work on it. AOT and LLVM support is still "experimental" for Android, so any new failing edge cases that can be provided to the engineering team are much appreciated. You can use this pre-formatted bug link so you only have to worry about the "Summary" and "Description", and then you can attach your test case and a brief description of the steps to reproduce. Thanks in advance! (Side note: there's also a chance the issue might be resolved in the current Cycle 6 "Release Candidate" that is currently available on the Alpha updater channel, in case you might like to experiment with that.)


    For the new error in Xamarin Studio, the error message is a bit more informative:

    Platform library directory for target Arm and API Level 23 was not found. Expected path is "/Users/jonathanyates/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/platforms/android-23/arch-arm/usr/lib"

    The AOT feature requires being able to use the cross-compilers and Android-API-level-specific native libraries that are shipped as part of the Android NDK. It sounds like the "r10d" release of the NDK cross-compiler toolchain does not include the libraries for API Level 23. You can check the android-ndk-r10d/platforms/ folder to see which platforms are supported by that NDK, and switch your application to target one of those.

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai

    Platform library directory for target Arm and API Level 23 was not found. Expected path is "/Users/jonathanyates/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/platforms/android-23/arch-arm/usr/lib"

    A small additional follow-up: the Cycle 6 "Release Candidate" includes some extra logic that allows Android API 23 projects to be AOT-compiled using the android-21 platform from the "r10d" NDK toolchain. That should in theory stop the error message for this particular pairing of versions.

  • jonathanyatesjonathanyates GBMember ✭✭✭

    @BrendanZagaeski

    In the end I have just turn off LLVM and it works. I don't really have time, or afford the risk, of trying C6 RC Alpha as this is an App Store release. Btw, is LLVM likely to improvement the running performance at all as some aspects of my app are sluggish on Android?

Sign In or Register to comment.