Lukasz S
Lukasz S

Reputation: 668

Deployment failed because of an internal error: An item with the same key has already been added

I'm using VS2013, Xamarin.Android 4.12.4.20.

Build is successful.

I'm getting error from title whenever I try to deploy in debug mode or package. It started to happened today it work fine before.

I've restarted VS, device, PC - none helped.

Stack trace:

Xamarin.AndroidTools.AndroidDeploymentException: InternalError ---> System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Mono.AndroidTools.Adb.AdbSyncDirectory.Add(AdbSyncItem entry)
   at Xamarin.AndroidTools.AndroidDeploySession.InstallAssemblies(String destinationPath, CancellationToken token)
   at Xamarin.AndroidTools.AndroidDeploySession.FastDev()
   at Xamarin.AndroidTools.AndroidDeploySession.Run(CancellationToken token)
   at Xamarin.AndroidTools.AndroidDeploySession.RunLogged(CancellationToken token)
   --- End of inner exception stack trace ---
   at Xamarin.AndroidTools.AndroidDeploySession.RunLogged(CancellationToken token)
   at Xamarin.AndroidTools.AndroidDeploySession.Start(CancellationToken token)

Build output:

3>Build succeeded.
3>Waiting for device..
3>Detecting installed packages
3>Detecting installed packages...
3>
3>Removing previous version of application
3>Removing previous version of application...
3>
3>Installing application on device
3>Copying application to device...
3>
3>Getting installation path...

Upvotes: 1

Views: 4121

Answers (1)

Lukasz S
Lukasz S

Reputation: 668

I've figured it out. Make sure that you don't have different versions of the same dll referenced!!

Let me describe my set up a bit more that will help with explaining why exception happened.

I've got two projects

  • Domain - library with code shared between all platforms
  • Android - android specific code

Both have nuget references to the same library. At some point android (only in this project) nuget references have been updated which resulted in two versions of the same library required by the application (Domain project still referenced old nuget).

When I tried to package solution I would get warning like :

Consider app.config remapping of assembly "{Library}" from Version "5.6.0.0" [] to Version "5.6.1.0" [{Path}] to solve conflict and get rid of warning.

Once I've update Domain's nuget everything worked.

Upvotes: 2

Related Questions