Rambam Melachim 11 states that Moshiach should be one who studies Torah:
"וְאִם יַעֲמֹד מֶלֶךְ מִבֵּית דָּוִד הוֹגֶה בַּתּוֹרָה וְעוֹסֵק בְּמִצְוֹת כְּדָוִד אָבִיו."
"Now, if a king should arise from the House of David who is versed in Torah and engages in Commandments, as did David his forefather"
[Strangely in Hichos Teshuvah (9:2)] Rambam also shows how great should Moshiach be in Torah study and prophecy:
"מִפְּנֵי שֶׁאוֹתוֹ הַמֶּלֶךְ שֶׁיַּעֲמֹד מִזֶּרַע דָּוִד בַּעַל חָכְמָה יִהְיֶה יֶתֶר מִשְּׁלֹמֹה.
וְנָבִיא גָּדוֹל הוּא קָרוֹב לְמשֶׁה רַבֵּנוּ. וּלְפִיכָךְ יְלַמֵּד כָּל הָעָם וְיוֹרֶה אוֹתָם דֶּרֶךְ ה'."
"as that king who will arise from the seed of David will be gifted with wisdom more than Solomon, and great in prophecy nigh unto Moses. He will, therefore, teach the whole people and point out to them the Lord's path"
However, from the following statement of his (in Melachim, based on the Gemmorah Yerushalmi Taanit 4:5):
"... רַבִּי עֲקִיבָא חָכָם גָּדוֹל מֵחַכְמֵי מִשְׁנָה הָיָה. וְהוּא הָיָה נוֹשֵׂא כֵּלָיו שֶׁל בֶּן כּוֹזִיבָא הַמֶּלֶךְ. וְהוּא הָיָה אוֹמֵר עָלָיו שֶׁהוּא הַמֶּלֶךְ הַמָּשִׁיחַ. וְדִמָּה הוּא וְכָל חַכְמֵי דּוֹרוֹ שֶׁהוּא הַמֶּלֶךְ הַמָּשִׁיחַ. עַד שֶׁנֶּהֱרַג בַּעֲוֹנוֹת.
For Rabbi Akiva, one of the wisest of the Sages of the Mishna, was King Ben Coziba’s arms-bearer and said that he was the King Messiah. He and all the Sages of his generation thought that he was the King Messiah, until he was killed because of his sins"
As we know, R' Akivah was the Gdol Hador and other Sages were far more knowledgeable than Bar Kochbah to say the least. I could not find any mentioning of B"K's sayings or wisdom in the Talmud, instead, he's only mentioned as a purely military leader, not a Chacham.
First, is there a contradiction in Rambam betweens his first view that the Moshiach should be "more intelligent than King Salomon" and R"Akiva's view that Bar Cochbah was the Moshiach despite his mediocracy?
Second, which way do we hold LeHalachah - should the Moshiach be Gdol Hador or just an exceptional military leader?