Two other possible causes are a urinary tract infection with urease producing bacteria such as Proteus, Staphylococcus or Klebsiella spp which commonly results in struvite bladder or kidney stones; or very rarely a type of kidney disease called distal renal tubular acidosis. You should get dog's urine tested for struvite crystals and for an infection. Distal renal tubular acidosis can be detected by blood work- it will show hyperchloremic metabolic acidosis.
If it's diet related, a high protein low carb diet will solve the problem , best diet would be a prey frozen raw food diet with some of your own vegetables thrown in on the side.