I had this issue too and tried all these solutions, but these general solutions will give you clues and not fix the problem. The problem is usually caused by something you've done and you have to follow the clues. Here's what happened
Aptitude does give you more details than apt-get, so run it. i ran it and it said
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libavcodec-dev [Not Installed]
2) libavdevice-dev [Not Installed]
3) libavfilter-dev [Not Installed]
4) libavformat-dev [Not Installed]
5) libavresample-dev [Not Installed]
6) libgazebo9-dev [Not Installed]
..." up to 25 packages
It did not succeed to install, and even when i clicked "Accept this solution Y" it still didnt work. But that list reminded me when I was fooling around with mpeg avcodec a while back . So i tried to install libavcodec-dev
I got:
The following packages have unmet dependencies:
libavcodec-dev : Depends: libavutil-dev (= 7:3.4.8-0ubuntu0.2) but 7:4.1.3-0york1~18.04 is to be installed
Depends: libswresample-dev (= 7:3.4.8-0ubuntu0.2) but it is not going to be installed
So i tried sudo apt-get install libswresample-dev
but got
The following packages have unmet dependencies:
libswresample-dev : Depends: libavutil-dev (= 7:3.4.8-0ubuntu0.2) but 7:4.1.3-0york1~18.04 is to be installed
E: Unable to correct problems, you have held broken packages.
So I tried
sudo apt-get install libavutil-dev
libavutil-dev is already the newest version (7:4.1.3-0york1~18.04).
NOW the issue is clear, when i was messing around with mpeg mp4 codecs I must have installed this york version (7:4.1.3-0york1~18.04) of the libavutil-dev package, which you can see from the errors will not work with libavcodec-dev, which blocks ros-melodic-desktop-full. So i removed that libavutil-dev and reinstalled it, which installed the correct package version (7:3.4.8-0ubuntu0.2)
REMOVE BAD VERSION:
sudo apt-get remove libavutil-dev
The following packages will be REMOVED:
libavutil-dev libswscale-dev
0 upgraded, 0 newly installed, 2 to remove and 103 not upgraded.
After this operation, 2,388 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 288297 files and directories currently installed.)
Removing libswscale-dev:amd64 (7:4.1.3-0york1~18.04) ...
Removing libavutil-dev:amd64 (7:4.1.3-0york1~18.04) ...
NOW REINSTALL THE GOOD VERSION
sudo apt-get install libavutil-dev
The following NEW packages will be installed:
libavutil-dev
0 upgraded, 1 newly installed, 0 to remove and 103 not upgraded.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 libavutil-dev amd64 7:3.4.8-0ubuntu0.2 [294 kB]
Preparing to unpack .../libavutil-dev_7%3a3.4.8-0ubuntu0.2_amd64.deb ...
Unpacking libavutil-dev:amd64 (7:3.4.8-0ubuntu0.2) ...
Setting up libavutil-dev:amd64 (7:3.4.8-0ubuntu0.2) ...
NOW I TRIED INSTALLING THOSE THINGS THAT WERE BLOCKED BY THE BAD PACKAGE AND THEY WORKED:
sudo apt-get install libswresample-dev
sudo apt-get install libavcodec-dev
sudo apt-get install ros-melodic-desktop-full
Success
Do you have Gazebo installed from the osrf repositories by any chance?
don't you mean "after running .."? That command only deletes a file, it does not ask
apt
to install any packages.I accidentally put the wrong command in my question. I have now updated it.
But did you install Gazebo sometime earlier and from the OSRF repositories?
Use aptitude as explained here. It guides you through fixing dependencies.