The country gained recognition of its independence in 1878 .