This is a subject of some dispute, but perhaps the most common view is that Hannibal probably crossed the Pyrenees via the mountain passes of modern Le Perthus.
He crossed the Pyrenees by the Col du Perthus, a relatively low pass near the eastern end of the mountains near the Mediterranean Sea. The Col du Oethus is less than 800 meters high and even in ancient times was an easy passage over the mountains.
- Prevas, John. Hannibal Crosses the Alps: the Invasion of Italy and the Punic Wars. Da Capo Press, 2009.
This is inferred from historical records. In his Histories, the Greek historian Polybius described Hannibal's passage through the Pyrenees as:
From Emporium to Narbo it is about six hundred stades ... this part of the road having now been carefully measured by the Romans and marked with milestones at every eighth stade (3:39:8).
This suggests that Polybius thought Hannibal followed an ancient route, one that the Romans later surveyed and paved as the Via Domitia. The Via Domitia leads into Iberia (where it links up with the Via Augusta) through the Col de Parnissars and its neighbouring Col du Perthus, both to the west of the Albères. During antiquity these were the main passes across the Pyrenees, and it would have been perfectly sensible for Hannibal to make his crossing here as well
The Via Domitia leads to the most popular (and lowest) pass in the eastern Pyrenees, the Col de Panissars, now known as the Col de Portus. Hannibal probably came through this pass in 218 BC.
- Salisbury, J. E. Rome's Christian Empress: Galla Placidia Rules at the Twilight of the Empire. JHU Press, 2015.
Another possibility on the Via Domitia route was the Col de Banyuls, which was closer to the Mediterranean coast. Some have suggested that Hannibal might have crossed here, but this is not considered likely because it would make the Carthaginians much more likely to be noticed.
The exact pass or passes by which the army went over the eastern spurs of the Pyrenees is not known, but J. Colin was of opinion that it was by the Col de Banyuls, about 360 metres high, 37 kilometres from Emporiae and 33 to Illiberis (Elne).
- De Beer, Gavin. Hannibal: Challenging Rome's Supremacy. Viking Press, 1969.
Both options are in the Eastern Pyrenees, a not inconsiderable distance from Andorra.
In addition to the Via Domitia passes, the other theory is that Hannibal crossed at the Col de Perche in the Central Pyrenees. This route, through the basin of the Segre as mentioned in the question, would indeed bring Hannibal close to Andorra, as the question's alternative hypothesis argues. However, it makes relatively less sense for Hannibal to choose this unnecessarily difficult path.
The main arguments for this route is that Hannibal may have chosen it so that he could defeat the nearby tribes. The military and strategic benefits of such a move is dubious, though. If the Carthaginians had any hopes for maintaining a logistical link to Spain, it was dashed within months.