The explosion damaged the roof of the building and one of the cows was treated for burns.
It's believed high levels of the gas had built up in the shed due to the cattle belching and farting.
Police say a static charge caused the gas to explode with flashes of flames.