To understand how to keep Al-Andalus alive you need to understand why it didn't succeed. The biggest problem as Lalli pointed our was disunity. Al-Andalus throughout its various incarnations (Emirate of Cordoba, Caliphate of Cordoba, Taifas, Almoravids and Almohads) was never a truly united state.
During the Umayyad era, the Emir/Caliph only ever had complete control of Cordoba and it's surrounding areas. Almost everywhere else in Al-Andalus formed some kind of semi-independence, whether that be in Zaragoza, Toledo or Sevilla, the Caliph's struggled to contain their own territories let alone the northern Christian states. This was due to the Spanish Umayyad's having a bit of a bastard system, a combination of tribal and imperial systems with the benefits of neither.
This meant that in theory, they could place loyalist dynasties/tribes in outside territories for levies whilst keeping a personal army in the capital, somewhat similar to the later Ottomans. However this didn't work out, as the families who were given governing duties almost never actually had loyalty to the Caliph, due to Muladis and Berbers having no kinship to the foreign Umayyad dynasty, and Arab dynasties almost always being self - serving. All the while, private armies of the Caliph would also be a problem, as they are expemsive and due to the trend that Islamic powers were generally untrusting of natives, had to hire foreign mercanries. Thus there was never a stable state, militarily. The Caliph could either choose to accept this status quo of de facto feudalism (in which none of the fiefs were truly loyal) or actively spend what could be years quelling dissent. It took exceptionally good leaders such as Abd-Ar-Rahman III and Al-Mansur to actually control the whole realm AND wage war against Leon, Navarre etc. Most of the border fighting were left to basically independent raiding parties, which is why the term "moors" rather than any sort of actual state is often used for the battles between Christians and Muslims in Iberia at this time.
If you want the Caliphate/Emirate to survive, you need a complete overhaul of the system, and that's not just an exceptionally good Caliph, that means something that literally changes the political landscape of all Al-Andalus, such as a grand - scale war that involves all Iberian powers (hint hint at my own TL

). From there you can reform the system in the same way Henry VIII reformed England's own Bastard feudalism, it probably also requires the Christian states to be weak and divided whilst this great change occurs.
And that's just for the Caliphate/Emirate. The Taifas are almost impossible to survive on their own as they were, they were weak and divided militarily, and existed in the generation after Al-Mansur had forced the Christians to ally against Al-Andalus for their own safety and whilst Sancho the Great pretty much united Christian Iberia into a cohesive reconquista force. Unless some kind of ultimate king amongst men manages to unite all the Taifas whilst Christian Iberia has a meltdown, it's just ASB for the Taifas to survive as they were.
The Almoravids and Almohads had their own set of problems. As North African powers, they viewed Al-Andalus as an afterthought, a colony of sorts. Something of a cash cow and a buffer zone, as well as a place to spread their own variations of Islam. For this reason, Andalusian Muslims were willing to ally with Christians against the North Africans who they saw as an even bigger threat and more foreign. This was due to their southern Amazigh origin and their religious zealot nature that alienated Iberian Muslims. Have either of them view Al-Andalus as and more integrated part of the territory and that will go along way. Perhaps some great Sultan can turn Ceuta or Tangiers into the Constantinople of the West, solving the problem of manpower being in the Maghreb whilst literally everything else was in Iberia. Their army system was much more competent than the Caliphate of Cordoba, but they alienated those who should have been their greatest supporters. It's probably actually easier to see the North African Empires survive than the Caliphate/Emirate on their own merit, however they existed in an era of Crusaders and the reconquista, making the context they existed in much harder to survive, even in the best case scenario.
So yes, there's a few ways to make Al-Andalus survive, most involve fixing the problems that doomed them OTL.